fork download
  1. <?php
  2. //the current array and an empty new array to get the result.
  3. $cur_array = [0 => "4,9", 1 => "5,9"];
  4. $new_array = [];
  5.  
  6. //run through all array values to convert these.
  7. for ($i = 0; $i < count($cur_array); $i++) {
  8.  
  9. //get an array of the comma separated list.
  10. $part = explode(',', $cur_array[$i]);
  11.  
  12. //add the array of comma separated list to the new array (result).
  13. $new_array = array_merge($new_array, $part);
  14. }
  15.  
  16. //convert all string values to integer values.
  17. for ($j = 0; $j < count($new_array); $j++) {
  18. $new_array[$j] = intval($new_array[$j]);
  19. }
  20.  
  21. //output of the new array (debug).
  22. var_dump($new_array);
Success #stdin #stdout 0s 82560KB
stdin
Standard input is empty
stdout
array(4) {
  [0]=>
  int(4)
  [1]=>
  int(9)
  [2]=>
  int(5)
  [3]=>
  int(9)
}