You are here: Re: preg_replace help « All PHP « IT news, forums, messages
Re: preg_replace help

Posted by Wolverine on 04/25/06 18:05

Sure, sorry for the clarity issues.

Ok, so I am selecting the user id's from the db into the user_array.
Once I have the user_array I need to replace all occurrences of key
with value in buffer. The buffer is html and I am replacing links to
userid key with userid value. In general, I would estimate that on any
given page the buffer contains at most 15% of the user id keys in
$user_array.

In more specific terms I need to replace 'u=$key' with
'user=$value'(i.e. str_replace('u=15', 'user=69', $buffer). This is
what I tried to explain about building an search and replace array for
str_replace. If I have 10k users I think this would hit performance
pretty hard if I built two arrays of size 10k and then passed them to
str_replace. In addition to the fact it would be processed each and
every load of the page. So my idea was to simply use regex to find all
instances of 'u=$key' and replace with 'user=$user_array[$key]'. This
way has to be more efficient but I didn't have any luck on my first
couple hours of trying.

Thanks for the help

 

Navigation:

[Reply to this 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

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