Re: Adding a more logical string slicing function to PHP

From: Date: Thu, 31 Mar 2011 15:45:52 +0000
Subject: Re: Adding a more logical string slicing function to PHP
References: 1 2 3 4 5 6 7 8 9 10 11  Groups: php.internals 
Request: Send a blank email to internals+get-51771@lists.php.net to get a copy of this message
On Mar 31, 2011, at 9:43 AM, Brian Moon wrote: >>> How would str_contains() be different from strstr()? >>> >>> >> They differ in the return type > > $instr = (bool)strstr($string1, $string2); > > done. No need for a new function. Well, to be clearer: bool str_contains( haystack, needle [, case_insensitive = false ] ) string str[i]str( haystack, needle [, $before_needle = false ] ) The main differences: - Return value is a bool - No ordinal value conversions (I assume) - No === usage worries/requirements - Intuitive name Regards, Philip

« previous php.internals (#51771) next »