note 64453 deleted from function.str-ireplace by bjori

From: Date: Fri, 14 Apr 2006 17:38:27 +0000
Subject: note 64453 deleted from function.str-ireplace by bjori
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-108098@lists.php.net to get a copy of this message
Note Submitter: Kerm Martian (www.cemetech.net) Reason: in docs ---- Here's a PHP 3/PHP 4 - compatible version. <?php function strireplace($needle,$replace,$haystack) { $where = 0; $strihay = strtolower($haystack); $needle = strtolower($needle); while ($where < strlen($haystack)) { $thiswhere = strpos($strihay,$needle,$where); if ($thiswhere === FALSE) { $where = strlen($haystack); } else { if ($where == 0) { $haystack = $replace . substr($haystack,strlen($needle),strlen($haystack) - strlen($needle)); } else if ($where == (strlen($haystack) - strlen($needle))) { $haystack = substr($haystack,0,strlen($haystack) - strlen($needle)) . $replace; } else { $haystack = substr($haystack,0,$where) . $replace . substr($haystack,$where+strlen($needle),strlen($haystack) - $where - strlen($needle)); } } $where++; } return $haystack; } ?>

« previous php.notes (#108098) next »