note 26346 deleted from function.ereg-replace by kennyt

From: Date: Wed, 26 Jan 2005 03:55:14 +0000
Subject: note 26346 deleted from function.ereg-replace by kennyt
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-83989@lists.php.net to get a copy of this message
Note Submitter: ---- function ereg_replace_multi($b,$text) { if (!is_array($b)) { trigger_error("First argument of <i>ereg_replace_multi</i> is no array.", E_USER_ERROR); } else { array_walk ($b, 'ereg_replace_mulit_sub',&$text); } return $text; } function ereg_replace_mulit_sub($item,$key,&$text) { //echo $item."--".$key."--".$text."<br>"; $text = ereg_replace($key,$item,$text); //echo $text."<br>"; } For example: $replacements = Array( "\."=>", "," "=>"", "\["=>"", "\]"=>"", "=>"=>"</td><td>", "\n"=>"</td></tr><tr><td>", "Array\("=>"<table><tr><td>", "\)"=>"</td></tr></table>"); $text = "Array ( \n[a] => 21.900513986645 \n[b] => 15.610694736298 \n[c] => 32.962099447699 \n[z] => ) "; echo ereg_replace_multi($replacements,$text);

« previous php.notes (#83989) next »