note 26346 added to function.ereg-replace

From: Date: Sun, 27 Oct 2002 14:12:21 +0000
Subject: note 26346 added to function.ereg-replace
Groups: php.notes 
Request: Send a blank email to php-notes+get-38621@lists.php.net to get a copy of this message
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); -- http://www.php.net/manual/en/function.ereg-replace.php http://master.php.net/manage/user-notes.php?action=edit+26346 http://master.php.net/manage/user-notes.php?action=delete+26346 http://master.php.net/manage/user-notes.php?action=reject+26346

« previous php.notes (#38621) next »