3v4l.org

run code in 300+ PHP versions simultaneously
<?php $result_array = array(); $str = "1=>aaabba;4=>bsbsbsb;7=>flkdsl;5=>jdsfkjhsfd;"; $temp_array = explode(";",$str); $temp_array = array_filter($temp_array); foreach($temp_array as $val) { $sub_temp_array = explode("=>",$val); $result_array[$sub_temp_array[0]] = $sub_temp_array[1]; } print_r($result_array);

preferences:
79.72 ms | 406 KiB | 5 Q