note 92170 added to function.strstr

From: Date: Sun, 12 Jul 2009 23:09:57 +0000
Subject: note 92170 added to function.strstr
Groups: php.notes 
Request: Send a blank email to php-notes+get-158210@lists.php.net to get a copy of this message
Because php 4.3 excludes a parameter it is a bad idea to directly call this function if you are writing a library with backwards compatibility. I've written a similar function here, though I have added a parameter to allow for insensitive or sensitive string seeking. NOTE: php 4.3 will also need a stripos function defined or this function will not work (you can find one of several in the manual for stripos) <?php function strstr_common($haystack, $needle, $part = false, $insensitive = false){ $pos = ($insensitive)?stripos($haystack, $needle, 0):strpos($haystack, $needle, 0); if($pos !== false){ if($part){ return substr($haystack, 0, $pos); }else{ return substr($haystack, $pos); } } return false; } ?> ---- Server IP: 208.69.120.35 Probable Submitter: 207.47.201.6 ---- Manual Page -- http://www.php.net/manual/en/function.strstr.php Edit -- https://master.php.net/note/edit/92170 Del: integrated -- https://master.php.net/note/delete/92170/integrated Del: useless -- https://master.php.net/note/delete/92170/useless Del: bad code -- https://master.php.net/note/delete/92170/bad+code Del: spam -- https://master.php.net/note/delete/92170/spam Del: non-english -- https://master.php.net/note/delete/92170/non-english Del: in docs -- https://master.php.net/note/delete/92170/in+docs Del: other reasons-- https://master.php.net/note/delete/92170 Reject -- https://master.php.net/note/reject/92170 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#158210) next »