What would be the most simple way to convert an integer to an array of numbers?
Example:
2468 should result in array(2,4,6,8).
2468
array(2,4,6,8)
You can use str_split and intval:
$number = 2468; $array = array_map('intval', str_split($number)); var_dump($array);
Which will give the following output:
array(4) { [0] => int(2) [1] => int(4) [2] => int(6) [3] => int(8) }
Demo