View Full Version : Which is faster strstr or substr?

Coastal Web
08-25-2009, 09:43 PM
Hi guys, l was just wondering which of these two would be a quicker, substr or strstr? I've got a function that runs through about 20 different checks similar to the one below and l wanted to know which method would be the most optimized?

if(!strstr($result[0], '<span'))

if(substr($result[0], 0, 5 ) != '<span')

mr e
08-25-2009, 09:51 PM
If you only want to check if one string occurs inside another, strpos() (http://www.php.net/manual/en/function.strpos.php)