PDA

View Full Version : pulling left most characters form string


kred
08-31-2005, 05:36 PM
Hi all,
I need to get the left 2 characters or first 2 characters for a string,
ie. the string would look like this:
$myStr="ny-newyork-restaurants";
all I need is to pull the "ny" and nothing else, what is the function for this.


Thanks
Ken

devinemke
08-31-2005, 06:15 PM
$myStr = 'ny-newyork-restaurants';
echo substr($myStr, 0, 2);

kred
08-31-2005, 06:26 PM
Thanks,