RE: [PHP] preg_replace flaw
| From: | John W. Holmes | Date: | Thu, 10 Apr 2003 10:08:25 +0000 |
| Subject: | RE: [PHP] preg_replace flaw | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-143301@lists.php.net to get a copy of this message | ||
Is there some way to relate 8000 or 8001 to the image name you want to
replace? Or do you just want the first pattern matched to be replaced
with $array[0], the next with $array[1], etc... ?
---John W. Holmes...
PHP Architect - A monthly magazine for PHP Professionals. Get your copy
today. http://www.phparch.com/
> -----Original Message-----
> From: Dan Rossi [mailto:daniel@electroteque.org]
> Sent: Thursday, April 10, 2003 6:34 AM
> To: Php-General
> Subject: [PHP] preg_replace flaw
>
> hi guys
>
> i have an issue
>
> say i have content with
>
> $content = "[f8000f] [f8001f]";
>
> i need to replace the keys within the brackets with images for
instance
>
> $disp = array (8000=>"replace one",8001=>"replace two");
>
> currently the code i intergated from a current function at work does
this
>
> foreach ($disp as $key=>$value) {
> $replaced = eregi_replace("\[f$key\f\]","$value",$content);
> }
>
> although on the second loop it'll obviously replace the first loop so
will
> only replace one of them.
>
> theroetically i need to do this so i can do the replace global for the
> entire content
>
> $find = array ("\[f8000\f\]","\[f8001\f\]");
> $replace = array("replace one","replace two");
>
> $replaced = ereg_replace($find,$replace,$content);
>
> but doesnt seem to work any ideas ?
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php