note 34162 added to function.ereg-replace
| From: | chatty at wp dot pl | Date: | Thu, 17 Jul 2003 11:18:35 +0000 |
| Subject: | note 34162 added to function.ereg-replace | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-52265@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
// IT WORKS!!
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."
");
$duperella = text_clean(1,$duperella,"dabra");
echo ($duperella."
");
// 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+34162
Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+34162&report=yes
Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+34162&report=yes