preg_replace flaw

From: Date: Thu, 10 Apr 2003 10:33:49 +0000
Subject: preg_replace flaw
Groups: php.general 
Request: Send a blank email to php-general+get-143293@lists.php.net to get a copy of this message
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 ?

« previous php.general (#143293) next »