--- On Wed, 9/24/08, Neal Slensker <[EMAIL PROTECTED]> wrote:

> I really prefer the tire sizes to be formated as a single
> number ie: 2454517
>  
> What I have done so far is:
>  
> $string = '245/45ZR17';
> $tiresizearray = preg_match_all(
> '/(?<digit>\d+)/', $string, $ptiresize);
> print_r($ptiresize[0]);
>  
> 1) If I don't specify the "[0]" in the
> print_r command I get the following answer below, and I
> don't know enough to understand why and thats ok because
> I have no shame is saying I have no idea what I am doing,
> other than trying to learn:
>  
> Array
> (
>     [0] => Array
>         (
>             [0] => 245
>             [1] => 45
>             [2] => 17
>         )
>     [digit] => Array
>         (
>             [0] => 245
>             [1] => 45
>             [2] => 17
>         )
>     [1] => Array
>         (
>             [0] => 245
>             [1] => 45
>             [2] => 17
>         )
> )
>  
> However if I do specify the [0] I get just the 3 lines
> which is the 1st part to what I want.  The 2nd part of what
> I want to accomplish is having a tire size that is one
> single number.  ie. 2454517.
>  
> Can anyone tell me how I can accomplish the filtering of
> data to get my preferred format of a single number and then
> assigned that single # to a variable.
>  
> For example:
>  
> $newsize =
> Array($tiresizearray[0].$tiresizearray[1].$tiresizearray[3])
>  
> I know the above line is wrong but hopefully someone
> understands what I am trying to do.  Any and all help is
> appreciated.
>  
> Sincerely,
>  
> Neal Slensker

First, it looks as if the [1] element of your array contains the values you 
want.  So, why not do something like:

$string = '245/45ZR17';
$tiresizearray = preg_match_all('/(?<digit>\d+)/', $string, $ptiresize);
$newsize = join("", $ptiresize[1]);

I can't get your regex to work.  I don't know how the <digit> will work in the 
regex.  However, if you can get the array generated then my code should work.

By the way, it looks as if you are merely trying to get rid of characters which 
are not numbers.  If they always followed the pattern you gave, you could use:

$string = '245/45ZR17';
$newsize = str_replace(array(' ','/','R','Z'), "", $string);

What do all of those numbers mean in tire sizes anyways?

James

Reply via email to