Jim Lucas wrote:
> Ashley M. Kirchner wrote:
>> I have an array that's created as follows:
>>
>>
>>
>> $string = "73G 146C 311- 309.1C";
>>
>>
>> Anyone want to take a stab at it?
>>
>>
>
> Conditionals are your friend!
>
> <plaintext><?php
>
> $string = "73G 146C 311- 309.1C";
>
> $arr = preg_split("/[\s]+/", $string);
>
> print_r($arr);
>
> foreach ( $arr AS $item ) {
> preg_match('|^(?P<location>\d+)\.?(?P<decimal>\d*)(?P<letter>[A-Z-])|',
> $item,
> $matches);
>
> print_r($matches);
> }
>
> ?>
>
or w/ preg_match_all:
<?php
$regex = '/(([0-9]+)([^0-9])((?:[0-9]|\s+)))/';
$string = "73G 146C 311- 309.1C";
preg_match_all( $regex , $string , $matches );
print_r( $matches )
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php