Reply to Re: Search and replace...xxx ago. How?

Your name:

Reply:


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

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация