Re: If the first four characters are "0000", then do {}
| From: | Andrew Ballard | Date: | Tue, 26 Jan 2010 04:23:14 +0000 |
| Subject: | Re: If the first four characters are "0000", then do {} | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-301458@lists.php.net to get a copy of this message | ||
On Mon, Jan 25, 2010 at 11:12 PM, Daevid Vincent <daevid@daevid.com> wrote:
>> >From what I understand, strpos() faster than a lot of other similar
>> string functions and much faster than regexps. You could do:
>>
>> if (strpos($mydata->restored, '0000') === 0) {
>> do_stuff();
>> }
>
> Ah. Clever use of the "== 0" (tripple equals not necessary).
> The OP needs to know if it's the first 4 or not and so position 0 would be
> the start. Very nice.
>
The triple equals IS necessary. If '0000' is not found at all in
$mydata->restored, strpos() will return false, and (false == 0) in
PHP.
Andrew