note 71106 deleted from function.stripos by tularis

From: Date: Sun, 12 Nov 2006 23:13:00 +0000
Subject: note 71106 deleted from function.stripos by tularis
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-119641@lists.php.net to get a copy of this message
Note Submitter: Christopher_Walker at ATT dot net Reason: useless ---- To be able to use the returned value 0 [zero/FALSE] to indicate that the needle was not found when the needle is also likely to be found at position 0, prepend a char not likely to be part of the needle string to the haystack: <?php $needle='a'; $haystack='ABC'; $xpos=stripos('*'.$haystack,$needle); if ($xpos>0) { $xpos=$xpos-1; //adjust the position with respect to $haystack echo 'Found at offset ' . $xpos; } else echo 'Not found'; ?>

« previous php.notes (#119641) next »