oracle259 Posted September 27, 2006 Share Posted September 27, 2006 I really hope u guys can help me on this one ???.[code]$match = str_replace("*", '', $string);$match = strlen($match);if ($match == 0) {return False; } else {return True;}[/code]From the code you can see the problem clearly that if no *** are present in the $string, $match = strlen($match) also returns 0 which does not work for me. How do i change this code to make sure that $match = 0 only when *** are present in the $string and replaced.Thanks. Quote Link to comment Share on other sites More sharing options...
sanfly Posted September 27, 2006 Share Posted September 27, 2006 Try putting speechmarks around the 0ie[code=php:0]$match = str_replace("*", '', $string);$match = strlen($match);if ($match == "0") {return False; } else {return True;}[/code] Quote Link to comment Share on other sites More sharing options...
oracle259 Posted September 27, 2006 Author Share Posted September 27, 2006 thanks for the tip...but why the " " Quote Link to comment Share on other sites More sharing options...
sanfly Posted September 27, 2006 Share Posted September 27, 2006 Actually, after reading this again i think I have the wrong end of the stickOne way to do it would to be to count the string length before and after the string replace, and have the "false" returned only if there is a difference in those two numbers and the second one comes back as 0eg[code=php:0]$count1 = strlen($string);$match = str_replace("*", '', $string);$match = strlen($match);if ($match == 0 AND ($count1 != $match)) {return False; } else {return True;}[/code]Is that more what you were after? Quote Link to comment Share on other sites More sharing options...
oracle259 Posted September 27, 2006 Author Share Posted September 27, 2006 i think this one is solved thanks Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.