2009-09-02, 12:49 AM
2009-09-03, 02:02 PM
(2009-09-01, 04:27 PM)Pirata Nervo Wrote: [ -> ]By the way, wouldn't strstr work too? (instead of preg_match)
strpos() works too and is faster than strstr (or preg_match).
2009-09-03, 02:14 PM
Use my_strpos.
2009-09-03, 02:35 PM
(2009-09-03, 02:14 PM)Tomm M Wrote: [ -> ]Use my_strpos.
More information about my_strpos: http://crossreference.mybboard.de/inc/fu...html#l4053
2009-09-03, 02:44 PM
I don't use strpos that much because if the position is 0 it will return 0 and if it fails it may return 0 as well
can be tricky
can be tricky
2009-09-03, 02:58 PM
Not really, it's nice and simple as long as you use ===. Examples from PHP: http://uk2.php.net/function.strpos
2009-09-03, 03:40 PM
Maybe that wasn't the function then, because I remember one that did the same or something similar but would return 0 in both cases.
I guess I should start using strpos then
I guess I should start using strpos then
2009-09-03, 03:57 PM
It will return practically whatever it feels like returning, to be honest, so you're right - but if you use the === operator you can check whether it returns 0 (as in, it's there in the string but at the beginning) or whether it returns false (as in, it doesn't exist anywhere in the string).
It's not really a question of whether you should start using it or not - - it's up to you what you use!
It's not really a question of whether you should start using it or not - - it's up to you what you use!
2009-09-03, 03:59 PM
Thanks for the suggestion
2009-09-04, 10:32 AM
In PHP, 0 == false == "" == "0" == null and probably a few other things. A bit confusing perhaps, but just the way it works.
my_strpos is probably unnecessary as its main aim was to handle Unicode characters, whereas URLs generally don't have them, and even if they did, doesn't really matter (and you don't really care about the actual position given out anyway since you only care about if the string occurs or not).
my_strpos is probably unnecessary as its main aim was to handle Unicode characters, whereas URLs generally don't have them, and even if they did, doesn't really matter (and you don't really care about the actual position given out anyway since you only care about if the string occurs or not).