3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $arr=Array ( 0 => Array ( "Title" => "La science des rêves", "Year" => "2006", "Director" => Array ( "Name" => "Michel Gondry", "BirthYear" => "1963", "BirthPlace" => "Versailles, Yvelines, France" ) ), 1 => Array ( "Title" => "Arizona Dream", "Year" => "1992", "Director" => Array ( "Name" => "Emir Kusturica", "BirthYear" => "1954", "BirthPlace" => "Sarajevo, Bosnia and Herzegovina, Yugoslavia" ) ) ); $ck=Array ( 0 => "Title", 1 => "Director.Name", 2 => "Director.BirthYear" ); $newarray=array(); $s=sizeof($arr); $ss=0; while($ss<$s) { foreach($ck as $ck2) { $k = explode(".",$ck2); if(sizeof($k) >1) $newarray[$ss][$ck2]=$arr[$ss][$k[0]][$k[1]]; else $newarray[$ss][$ck2]=$arr[$ss][$k[0]]; $ss++; } } print_r($newarray);
Output for 5.3.0 - 5.6.28, 7.0.0 - 7.1.0
Notice: Undefined offset: 2 in /in/ZiFBH on line 51 Array ( [0] => Array ( [Title] => La science des rêves ) [1] => Array ( [Director.Name] => Emir Kusturica ) [2] => Array ( [Director.BirthYear] => ) )
Output for hhvm-3.10.0 - 3.12.0
Notice: Undefined index: 2 in /in/ZiFBH on line 51 Array ( [0] => Array ( [Title] => La science des rêves ) [1] => Array ( [Director.Name] => Emir Kusturica ) [2] => Array ( [Director.BirthYear] => ) )
Output for 4.3.0 - 5.2.17
Notice: Undefined offset: 2 in /in/ZiFBH on line 51 Array ( [0] => Array ( [Title] => La science des rêves ) [1] => Array ( [Director.Name] => Emir Kusturica ) [2] => Array ( [Director.BirthYear] => ) )