note 21948 added to function.str-replace

From: Date: Fri, 31 May 2002 20:47:38 +0000
Subject: note 21948 added to function.str-replace
Groups: php.notes 
Request: Send a blank email to php-notes+get-31311@lists.php.net to get a copy of this message
It brings a false sentence: <? $string="135.728.189-57"; $string2=(str_replace(".","",$string)) && (str_replace("-","",$string)); if ( ($string2=="") || (!is_numeric($string2)) ) { echo "<font color=\"red\">Not a number !</font>"; } else { echo $string; } ?> In this case, it returns $string="error" and $string2="1" That was my trouble but I solved my own trouble ! I don't know y but PHP function str_replace() does not accept more than one conditions (it does not receive, I do not know the right word...) but if u`re trying to make the sence i told up there, u have to use another code. Note: <? $string1="123.456.789-10" $string2=(str_replace(".","",$string1); $string2=(str_replace("-","",$string2); echo $string2; //it gotta return "12345678910" //or u should use: $string1="123.456.789-10"; $string2=(str_replace(".","",str_replace("-","",$string1))); echo $string2; // it gotta return "12345678910" ?> As u see, we have the same result but I don't know if that PHP error may be called a bug ... Edden !!!! thanx ;^) ?> -- http://www.php.net/manual/en/function.str-replace.php http://master.php.net/manage/user-notes.php?action=edit+21948 http://master.php.net/manage/user-notes.php?action=delete+21948 http://master.php.net/manage/user-notes.php?action=reject+21948

« previous php.notes (#31311) next »