fork download
  1. <?php
  2.  
  3. $str = "2,1";
  4.  
  5. $str = array_map(function($value){
  6. return intval($value);
  7. }, explode(",", $str));
  8.  
  9.  
  10. var_dump($str);
Success #stdin #stdout 0.01s 82880KB
stdin
Standard input is empty
stdout
array(2) {
  [0]=>
  int(2)
  [1]=>
  int(1)
}