<?php $n = 1234567890; for ($i = $k = 0; (int)$n; $n /= 10) { $k += $i++ % 3 == 0 ? 1 : 0; $nn[$k][] = $n % 10; } print_r($nn);