Page 1 of 1

What function should I use?

Posted: Tue Jun 08, 2010 1:46 pm
by tonykasdorf
I'm looking for the following functions. Can someone fill in the ?.

$string = "8.5 x 11";

echo $x = ?;
//prints out: "8.5"
echo $y = ?;
//prints out: "11"

Thanks

Re: What function should I use?

Posted: Tue Jun 08, 2010 1:53 pm
by AbraCadaver
Depends... If the x and the spaces are constant I would use explode().

Re: What function should I use?

Posted: Tue Jun 08, 2010 2:02 pm
by tonykasdorf
Yes, the "space" "x" "space" are constants. the two numbers at the beginning and end of the string are always changing. The numbers will very in size from two to four numbers in length.

I'm looking for the code that can break the two numbers up and give them to me in two separate variables.

Re: What function should I use?

Posted: Tue Jun 08, 2010 2:08 pm
by John Cartwright
Right.. then explode()