note 15282 deleted from function.strpos by jimw

From: Date: Thu, 18 Oct 2001 21:23:24 +0000
Subject: note 15282 deleted from function.strpos by jimw
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-19111@lists.php.net to get a copy of this message
There is an insanely easy way to test for no match: $test = strpos("test string", "test"); if ($test) { print "String Found"; } else { print "String not found"; } The return value for strpos() is an integer which is zero-based. If it doesn't find a match, it returns an empty integer (NOT zero). Try telling it to find something that you know won't find a match and then print the return value: nothing prints, therefor the return value is undefined. You're creating a lot more work for you and the server by doing all those other tests.

« previous php.notes (#19111) next »