Hi Michael,
I don't know if this will help but I created this function that will split the alphanumeric string into the Letter and the number; it returns an array('number'=>10000, 'string'=>'A');
Here is the function:
PHP Code:
function split_alphanumeric($string){
preg_match_all('/([\d]+)/',$string, $num_target); // matches just the numbers
preg_match_all('/[a-zA-Z]/', $string, $str_target); // matches just the alpha character(s)
$num = null;
$num = $num_target[0][0];
$str = null;
$str = $str_target[0][0];
$values = array();
$values['number'] = (int)$num;
$values['string'] = $str;
return $values;
}
And using it:
PHP Code:
$string = 'A10000';
$values = split_alphanumeric($string);
echo '<pre>';var_dump($values); echo "</pre>";
Creates this:
Code:
array(2) {["number"]=> int(10000) ["string"]=> string(1) "A" }
It would always create an array for the start of the range and would need to be recalled for the ending of the range. Alternatively the regex could be embedded in your function.
Steve
Bookmarks