note 86757 added to function.str-replace
| From: | luruke at osu1 dot php dot net | Date: | Sun, 02 Nov 2008 11:29:28 +0000 |
| Subject: | note 86757 added to function.str-replace | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-146039@lists.php.net to get a copy of this message | ||
My str_replace() implementation:
<?php
function replace($search, $replace, $subject){
$subject .= " ";
for($temp="",$array=array(),$j=0,$i=0;$i<strlen($subject);$i++){
if($subject{$i} <> " "){
$temp .= $subject{$i};
} else {
$array[$j] = $temp; $j++; $temp = "";
}
}
for($i=0;$i<count($array);$i++)
if($array[$i] == $search)
$array[$i] = $replace;
for($res="",$i=0;$i<count($array);$i++)
if($i<count($array)-1)
$res .= $array[$i]." ";
else
$res .= $array[$i];
return $res;
}
print replace("blacklight", "luruke", "blacklight e' hacker");
?>
----
Server IP: 213.92.11.19
Probable Submitter: 151.53.48.127
----
Manual Page -- http://www.php.net/manual/en/function.str-replace.php
Edit -- https://master.php.net/note/edit/86757
Del: integrated -- https://master.php.net/note/delete/86757/integrated
Del: useless -- https://master.php.net/note/delete/86757/useless
Del: bad code -- https://master.php.net/note/delete/86757/bad+code
Del: spam -- https://master.php.net/note/delete/86757/spam
Del: non-english -- https://master.php.net/note/delete/86757/non-english
Del: in docs -- https://master.php.net/note/delete/86757/in+docs
Del: other reasons-- https://master.php.net/note/delete/86757
Reject -- https://master.php.net/note/reject/86757
Search -- https://master.php.net/manage/user-notes.php