3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php #$str = 'subvar'; #var_dump(explode(':',$str)); exit; $arr = array(); function strAssign(&$arr,$str,$val){ if(!empty($str)){ $str = explode(':',$str); $key = array_shift($str); $arr[$key] = strAssign($arr[$key],implode(':',$str),$val); }else{ return true; } } strAssign($arr,'var:sub:sub2','value'); var_dump($arr);
based on gc4Ur
Output for 4.3.0 - 7.2.0
array(1) { ["var"]=> NULL }