miless Posted July 1, 2008 Share Posted July 1, 2008 Is there any way for str_ireplace to return TRUE or FALSE in an IF ? The following code returns: "results true" ! $host = "name"; if ( str_ireplace(array("array", "array2", "array3"), "", $host) ==true ) {print "results true"; } else{ print "results false"; } Quote Link to comment https://forums.phpfreaks.com/topic/112743-solved-str_ireplace-true-or-false/ Share on other sites More sharing options...
trq Posted July 1, 2008 Share Posted July 1, 2008 Check the manual, str_ireplace does not return a bool. Quote Link to comment https://forums.phpfreaks.com/topic/112743-solved-str_ireplace-true-or-false/#findComment-579029 Share on other sites More sharing options...
papaface Posted July 1, 2008 Share Posted July 1, 2008 No because that function is designed to return a string or an array, not a boolean. Quote Link to comment https://forums.phpfreaks.com/topic/112743-solved-str_ireplace-true-or-false/#findComment-579031 Share on other sites More sharing options...
sasa Posted July 1, 2008 Share Posted July 1, 2008 try <?php $host = "name"; str_ireplace(array("array", "array2", "array3"), "", $host, $test); if ($test > 0) {print "results true"; } else{ print "results false"; }?> Quote Link to comment https://forums.phpfreaks.com/topic/112743-solved-str_ireplace-true-or-false/#findComment-579036 Share on other sites More sharing options...
trq Posted July 1, 2008 Share Posted July 1, 2008 Hehe... maybe I should practice what I preach and check the manual myself before posting occasionally. Quote Link to comment https://forums.phpfreaks.com/topic/112743-solved-str_ireplace-true-or-false/#findComment-579039 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.