|
Posted by Michael Fesser on 07/19/07 17:51
..oO(FFMG)
>I have some cached pages and I want to display how long ago certain
>articles were written.
>
>But how can I display "This article was written 'yyy days' ago" when
>the whole page is cached?
>
>I cannot do a simple search and replace as I would need to know when
>the articles were written to compare them with the current time, (I
>have more than one article with different dates saved in the pages).
>
>I was thinking of tags, something like '<%article date=xxxxx>'.
>And preg_replace( "/<%article date=(xxx)>/", ('yyyy'), $data );
>
>But how can I use the 'xxx' to calculate the 'yyy'?
Try preg_replace_callback() instead. It will receive an array of all
matched elements in the search string. Do your calculation there and
return the result.
Micha
Navigation:
[Reply to this message]
|