note 104932 added to function.strrpos

From: Date: Sat, 16 Jul 2011 19:18:53 +0000
Subject: note 104932 added to function.strrpos
Groups: php.notes 
Request: Send a blank email to php-notes+get-181592@lists.php.net to get a copy of this message
Generally, with any language that has a functional strpos function you can coin a quality instr function with relative ease. E.g. Borland Delphi 7 doesn't feature an instr method but conveniently it had a strpos method. I utilized this to create a nice, little instr snippet. I won't be posting the code because that'd be somewhat irrelevant, but I will post my PHP port of the snippet. function instr($haystack, $needle) { $pos = strpos($haystack, $needle, 0); if ($pos != 0) return true; return false; } Trimmed to near perfection. Example Usage (Self-explanatory but might as well demonstrate it for the heck of it): <?php $var = "bowchickawowwow"; if (instr($var, "chicka")) print "needle found in the haystack!"; function instr($haystack, $needle) { $pos = strpos($haystack, $needle, 0); if ($pos != 0) return true; return false; } ?> ---- Server IP: 69.147.83.197 Probable Submitter: 70.240.137.58 ---- Manual Page -- http://www.php.net/manual/en/function.strrpos.php Edit -- https://master.php.net/note/edit/104932 Del: integrated -- https://master.php.net/note/delete/104932/integrated Del: useless -- https://master.php.net/note/delete/104932/useless Del: bad code -- https://master.php.net/note/delete/104932/bad+code Del: spam -- https://master.php.net/note/delete/104932/spam Del: non-english -- https://master.php.net/note/delete/104932/non-english Del: in docs -- https://master.php.net/note/delete/104932/in+docs Del: other reasons-- https://master.php.net/note/delete/104932 Reject -- https://master.php.net/note/reject/104932 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#181592) next »