3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php #$str = 'subvar'; #var_dump(explode(':',$str)); exit; $arr = array('var'=> 'notouch'); function strAssign(&$arr,$str,$val){ if(!empty($str)){ $str = explode(':',$str); $key = array_shift($str); if(gettype($arr[$key])!='array' || !isset($arr[$key])){ $arr[$key] = array(); } strAssign($arr[$key],implode(':',$str),$val); }else{ $arr = $val; } } strAssign($arr,'var:sub:sub2','value'); var_dump($arr);
based on vr73P