Profile image for Cory Borrow coryborrow
Returns true or false if a string starts with another specified string.
Language
PHP
Tags
php starts string with
Favorited By
Profile image for Carly Ho

starts_with

1 function starts_with($haystack, $needle) { 2 return (substr($haystack, 0, strlen($needle)) == $needle); 3 }

Comments

Profile image for Patrick Sparrow psparrow 2011-11-01

How about:

return (strpos($haystack, $needle) === 0) ; ?