note 111422 added to function.strpos

From: Date: Mon, 18 Feb 2013 21:55:56 +0000
Subject: note 111422 added to function.strpos
Groups: php.notes 
Request: Send a blank email to php-notes+get-193675@lists.php.net to get a copy of this message
The most straightforward way to prevent this function from returning 0 is: strpos('x'.$haystack, $needle, 1) The 'x' is simply a garbage character which is only there to move everything 1 position. The number 1 is there to make sure that this 'x' is ignored in the search. This way, if $haystack starts with $needle, then the function returns 1 (rather than 0). ---- Server IP: 69.147.83.199 Probable Submitter: 75.39.123.81 ---- Manual Page -- http://php.net/manual/en/function.strpos.php Edit -- https://master.php.net/note/edit/111422 Del: integrated -- https://master.php.net/note/delete/111422/integrated Del: useless -- https://master.php.net/note/delete/111422/useless Del: bad code -- https://master.php.net/note/delete/111422/bad+code Del: spam -- https://master.php.net/note/delete/111422/spam Del: non-english -- https://master.php.net/note/delete/111422/non-english Del: in docs -- https://master.php.net/note/delete/111422/in+docs Del: other reasons-- https://master.php.net/note/delete/111422 Reject -- https://master.php.net/note/reject/111422 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#193675) next »