note 107345 modified in function.strtr by danbrown

From: Date: Thu, 10 May 2012 21:25:28 +0000
Subject: note 107345 modified in function.strtr by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-187883@lists.php.net to get a copy of this message
Case Insensitive strtr&#13;&#10;&#13;&#10;&#60;?php&#13;&#10;function stritr($string, $one, $two=null) {&#13;&#10; if (is_string($one)) {&#13;&#10; return strtr($string, strtoupper($one) . strtolower($one), &#34;$two$two&#34;);&#13;&#10; } else if (is_array($one)) {&#13;&#10; $strReturn = $string&#13;&#10; foreach ($one as $key =&#62; $val) {&#13;&#10; $strReturn = preg_replace(&#34;&#39;$key&#39;i&#34;, $val, $strReturn);&#13;&#10; }&#13;&#10; return $strReturn;&#13;&#10; }&#13;&#10; return $string;&#13;&#10;}&#13;&#10;?&#62; --was-- <?php // Case Insensitive strtr function stritr($string, $one, $two=null) { if (is_string($one)) { return strtr($string, strtoupper($one) . strtolower($one), "$two$two"); } else if (is_array($one)) { $strReturn = $string foreach ($one as $key => $val) { $strReturn = preg_replace("'$key'i", $val, $strReturn); } return $strReturn; } return $string; } ?> http://php.net/manual/en/function.strtr.php

« previous php.notes (#187883) next »