note 21948 deleted from function.str-replace by victor

From: Date: Sat, 09 Nov 2002 18:09:57 +0000
Subject: note 21948 deleted from function.str-replace by victor
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-39229@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 ;^) ?>

« previous php.notes (#39229) next »