note 40726 added to function.strpos
| From: | oaev at mail dot ru | Date: | Fri, 12 Mar 2004 12:06:28 +0000 |
| Subject: | note 40726 added to function.strpos | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-66711@lists.php.net to get a copy of this message | ||
Here is an example of removal illegal symbols from string in array. It works much faster than code
with regexp usage:
$text='This $tring cont@in$ ## of i\\lega\\ symb*ls';
$illegal=array('@',"$",'^','*','#','\\\\',':',';','<','>');
$garb=array();
foreach($illegal as $k) while(($j=strpos($text,$k))!==false){$garb[]=$text{$j};
$text=substr($text,0,$j).substr($text,$j+1);}
$garb=array_unique($garb);
after that $text will contain "This tring contin s of ilega symbls" and in $garb there
will be @$*#\\ symbols.
----
Manual Page -- http://www.php.net/manual/en/function.strpos.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+40726
Delete -- http://master.php.net/manage/user-notes.php?action=delete+40726&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+40726&report=yes
Search -- http://master.php.net/manage/user-notes.php