How to split a group of numbers to an array in PHP?

To split a number 187954 to an array as follows:

<?php
          $x=187954;
          $y=(string)$x;
          echo $y[0]."<br/>";  //1
          echo $y[1]."<br/>";  //8
          echo $y[2]."<br/>";  //7
          echo $y[3]."<br/>";  //9
          echo $y[4]."<br/>";  //5
          echo $y[5]."<br/>";  //4
?>

The Output will be as follows:

    1
    8
    7
    9
    5
    4

Leave a Reply