tags:

views:

90

answers:

1

This is what i have.

$number = 25880;

I need to break that up into individual lines in an array so i can read it like this

$numbers['1'] = 2
$numbers['2'] = 5
$numbers['3'] = 8
$numbers['4'] = 8
$numbers['5'] = 0

How do i do this in php?

+7  A: 

You can just use string functions as PHP will convert the number into a string before dealing with it.

$value = "0" . $number;
$numbers = str_split($value);

It doesn't do exactly what you want, as in PHP arrays are 0 indexed - but prepending the "0" will put the "real" contents where you asked for them.

Yacoby
nice one.
Zed