Re: int to array

From: Date: Fri, 15 Dec 2000 03:10:52 +0000
Subject: Re: int to array
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-30445@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];
Well, one way is to define the number as a string:
        $testString = '123456789';
or
        $test = 123456789;
        $testString = (string)$test;
Now - since you can treat strings as an array of characters - you can say
        echo $testString[0].$testString[2].$testString[5];
-steve http://www.php.net/manual/language.types.type-juggling.php#language.types.ty pecasting +------------------------------------------------------------------------+
| Steve Edberg                           University of California, Davis |
| sbedberg@ucdavis.edu                                     (530)754-9127 |
| http://aesric.ucdavis.edu/                  http://pgfsun.ucdavis.edu/ |
+---------------------- Gort, Klaatu barada nikto! ----------------------+

« previous php.general (#30445) next »