3v4l.org

run code in 300+ PHP versions simultaneously
<?php $str = '33|ts|6|ank|5|ist|4|bjk|2|fb|1|gs'; $explode = explode('|', $str); $parcala = array_chunk($explode, 2); $arr = []; foreach ($parcala as $item) { $arr[$item[0]] = $item[1]; } print_r($arr);

preferences:
28.63 ms | 406 KiB | 5 Q