fork download
  1. <?php
  2.  
  3. $s = '1234567890';
  4. if (preg_match('~\A\d+\z~', $s)) { // if a string is all digits
  5. print_r(str_split($s)); // Split it into chars
  6. }
Success #stdin #stdout 0.01s 23544KB
stdin
Standard input is empty
stdout
Array
(
    [0] => 1
    [1] => 2
    [2] => 3
    [3] => 4
    [4] => 5
    [5] => 6
    [6] => 7
    [7] => 8
    [8] => 9
    [9] => 0
)