|
Posted by Erwin Moller on 03/09/06 11:11
Paul Morrison wrote:
> Hi
>
> I have looked at the PHP string functions and I cant see any function to
> check to see whether a string starts with a certain letter or letters. Is
> there any way of doing this with the built in functions?
>
> Cheers,
>
> Paul
Hi Paul,
You can do this in many way, but the easiest way is just get the first
character of the string using substr(), and compare it to what you want.
It is here:
http://nl2.php.net/manual/en/function.substr.php
if (substr('abcd',0,1) == 'a') ...
(Of course, if you like regexpr you can use them too. search for regexpr at
www.php.net for regexpr-functions)
Regards,
Erwin Moller
[Back to original message]
|