note 34135 added to function.ereg-replace

From: Date: Wed, 16 Jul 2003 21:56:06 +0000
Subject: note 34135 added to function.ereg-replace
Groups: php.notes 
Request: Send a blank email to php-notes+get-52231@lists.php.net to get a copy of this message
Hi, I'm a php begginer, and i writed for myself a simmilar function to ereg_replace but, my function don't replace but dell from the text input words. I don't know why I write it, if is ready simmilar function in php, meaby becouse i was bored. Check this, meaby its faster that erg replace! ;-) // text cleaner by chatty function text_clean ($typpracy,$txt, $searched) { $veryf=0; $ttx=$txt; for ($index=0;$index < strlen ($txt);$index++) { $veryf=0; for ( $index2=0;$index2 < strlen ($searched);$index2++ ) { $comando=$index+$index2; if ( $searched[$index2]==$txt[$comando] ) {$veryf++;} } if ($veryf == strlen($searched) ) { for ( $index3=0;$index3 < strlen ($searched);$index3++ ) { $ttx[$index3+$index]=","; } // if typpracy ==0 then clean first met word and stop // if typpracy ==1 then clean text from all met that word if ( $typpracy == 0 )break; $veryf=0; } } return $ttx; } $duperella = "kadabrakadabrakadabrakadabraM"; echo ($duperella."<BR>"); $duperella = text_clean(1,$duperella,"dabra"); echo ($duperella."<BR>"); // POLAND IS COOL :-) ---- Manual Page -- http://www.php.net/manual/en/function.ereg-replace.php Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+34135 Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+34135&report=yes Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+34135&report=yes

« previous php.notes (#52231) next »