Another n00b question.
$ab = "A00000001"
echo $a; // gives result "A"
echo $b; // gives result "1"
$ab = "B01250"
echo $a; // gives result "B"
echo $b; // gives result "1250"
What's the easiet single way to convert "ab" to "a" and "b" in both examples above?
Thanks!
$ab = "A0000000001";
$a = substr( $ab, 0, 1 );
$b = (int)substr( $ab, 1 );
More information about substr can be found here: http://us.php.net/substr
You can do that with a regex:
$match = preg_match('@^(\w+)(\d+)@', $input);
$letter = $match[1];
$number = $match[2];
This is shorter, if that's what you mean by "easiet single way":
list($a,$b) = preg_split('/0+/',$ab);
Adjust your regex if you like: http://us.php.net/manual/en/function.preg-split.php