<?php $str = "2,1"; $str = array_map(function($value){ return intval($value); }, explode(",", $str)); var_dump($str);
Standard input is empty
array(2) { [0]=> int(2) [1]=> int(1) }
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!