Click to See Complete Forum and Search --> : Splitting part of a variable


damon2003
10-31-2003, 06:00 AM
I have a variable that echoes this:

echo$var;
worddescriptionhere numberhere

I need to know a method os splitting the first part which is text from the second half of the variable which is a number, and puting them in their own seaparate variables. I can place as many spaces between the text and number as necessary or place symbols there,
any ideas?

pyro
10-31-2003, 07:42 AM
A space will work fine, as would pretty much any non-alphanumeric character.

<?PHP
$str = "text 123";
list ($text, $num) = split(" ", $str);
echo "$text <br> $num";
?>