3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $string = '|23&65|567&89.7|90&65.35'; $ar = explode("|", $string); $ar = array_slice($ar, 1, sizeof($ar)); $ir = array(); foreach($ar as $key => $a) { $er = explode('&', $a); $ir[$key]['id_dispositivo'] = $er[0]; $ir[$key]['vl_dispositivo'] = $er[1]; } echo(var_dump($ir));
Output for 4.3.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
array(3) { [0]=> array(2) { ["id_dispositivo"]=> string(2) "23" ["vl_dispositivo"]=> string(2) "65" } [1]=> array(2) { ["id_dispositivo"]=> string(3) "567" ["vl_dispositivo"]=> string(4) "89.7" } [2]=> array(2) { ["id_dispositivo"]=> string(2) "90" ["vl_dispositivo"]=> string(5) "65.35" } }