Re: int to array
| From: | Philip Olson | Date: | Fri, 15 Dec 2000 04:40:55 +0000 |
| Subject: | Re: int to array | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-30447@lists.php.net to get a copy of this message | ||
> At 04:08 PM 12/14/00 , Jerry Lake wrote:
> >how do I turn a number in to an array
> >i.e. $test=123456789;
> >$test = array($test);
> >echo $test[0]$test[2]$test[5];
Try this :
$test = 34589439;
$test = preg_split('//', $test, 0, PREG_SPLIT_NO_EMPTY);
print $test[0]; // prints 3 , 3 is now a string
Now if you wanted the values to be integers you could then (after the
preg_split) do something like this :
foreach ($test as $key => $value) {
$iTest[$key] = (int) $value;
}
print $iTest[0]; // prints 3 but now 3 is an integer
I'm not the best at this sort of thing <G> but the above works, perhaps
this is what you wanted, an array full of ints.
regards,
philip
--
be outside the box.