I am having a brain freeze!
I have this:
$a = "abcdedf"; $b = "abc";
What I want to do is see if $a starts with $b. If it does print 1 otherwise prints 0.
Any quick ideas? The manual looks like a blurr at the moment. Hahha..
Thanks,
Rob
What you're looking for is strpos().
<?php $a = 'abcdefg'; $b = 'abc'; if (strpos ($a, $b) === 0) { echo '$a starts with $b'; } elseif (strpos ($a, $b) === false) { echo '$b is not in $a'; } else { echo '$b is in $a at position: ' . strpos ($a, $b); } ?>
For more info, see:
http://www.php.net/strpos
Cheers,
Lux