[thelist] PHP, 8 digit string, to 8 item array..

Ken Snyder ksnyder at coremr.com
Tue Jan 16 10:06:03 CST 2007


Tris wrote:
> I wanna take an Int (eg: 48392034)
> and make an array:
> $myArray[0] = 4;
> $myArray[1] = 8;
> $myArray[2] = 3;
> ...

// PHP5 only: 
str_split((string)48392034,1);

// PHP4+ string access by brackets
$intString = (string)4892034;
$myArray = array();
for( $i=0; $i<strlen($intString); $i++ ) {
  $myArray[] = $intString{$i};
}



More information about the thelist mailing list