3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $files=array("Expurgo", "Famosos e Etc/Ego", "Famosos e Etc/Ego/40 Graus", "Famosos e Etc/Ego/40 Graus/Home", "Famosos e Etc/Ego/Beleza", "Famosos e Etc/Ego/Beleza/Home", "Famosos e Etc/Ego/Carnaval", "Famosos e Etc/Ego/Especiais/Avon", "Famosos e Etc/Ego/Especiais/Dia das Maes", "Famosos e Etc/Ego/Especiais/Lollapalooza", "Famosos e Etc/Ego/Especiais/Lollapalooza/Home", "Famosos e Etc/Ego/Especiais/Loreal", "Famosos e Etc/Ego/Especiais/Malwee", "Famosos e Etc/Ego/Especiais/Natal", "Famosos e Etc/Ego/Especiais/Pascoa", "Famosos e Etc/Ego/Especiais/Rock in Rio", "Famosos e Etc/Ego/Especiais/Rock in Rio/Home", "Famosos e Etc/Ego/Especiais/The Body Shop", "Famosos e Etc/Ego/Gravidez", "Famosos e Etc/Ego/Gravidez/Home", "Famosos e Etc/Ego/Home", "Famosos e Etc/Ego/Horoscopo", "Famosos e Etc/Ego/Horoscopo/Home", "Famosos e Etc/Ego/Moda", "Famosos e Etc/Ego/Moda/Home", "Famosos e Etc/Ego/Teen", "Famosos e Etc/Ego/Teen/Home", "Famosos e Etc/Home", "G1/Agronegocios", "G1/Agronegocios/Home", "G1/Bem Estar", "G1/Bem Estar/Home", "G1/Blogs e Colunas", "G1/Blogs e Colunas/Altieres Rohr", "G1/Blogs e Colunas/Alysson Muotri", "G1/Blogs e Colunas/Andrea Ramal", "G1/Blogs e Colunas/Bruno Medina", "G1/Blogs e Colunas/Cassio Barbosa", "G1/Blogs e Colunas/Cristina Lobo", "G1/Blogs e Colunas/Geneton Moraes Neto", "G1/Blogs e Colunas/Luciano Trigo", "G1/Blogs e Colunas/Paulo Coelho", "G1/Blogs e Colunas/Redacao", "G1/Blogs e Colunas/Ronaldo Prass", "G1/Blogs e Colunas/Sergio Nogueira", "G1/Blogs e Colunas/Startup", "G1/Blogs e Colunas/Thais Heredia", "G1/Blogs e Colunas/Viver Noronha", "G1/Blogs e Colunas/Yvonne Maggie", "G1/Blogs e Colunas/Zeca Camargo"); $master_array=array(); foreach($files as $file) { $file=explode("/",$file); $cache=end($file); while($level=prev($file)) { $cache=array($level=>$cache); } $master_array=array_merge_recursive($master_array,$cache); } print_r($master_array);
based on 2g2Br
Output for 5.0.0 - 7.2.0
Warning: array_merge_recursive(): Argument #2 is not an array in /in/ZT4XJ on line 62 Warning: array_merge_recursive(): Argument #1 is not an array in /in/ZT4XJ on line 62 Warning: array_merge_recursive(): Argument #1 is not an array in /in/ZT4XJ on line 62 Warning: array_merge_recursive(): Argument #1 is not an array in /in/ZT4XJ on line 62 Warning: array_merge_recursive(): Argument #1 is not an array in /in/ZT4XJ on line 62 Warning: array_merge_recursive(): Argument #1 is not an array in /in/ZT4XJ on line 62 Warning: array_merge_recursive(): Argument #1 is not an array in /in/ZT4XJ on line 62 Warning: array_merge_recursive(): Argument #1 is not an array in /in/ZT4XJ on line 62 Warning: array_merge_recursive(): Argument #1 is not an array in /in/ZT4XJ on line 62 Warning: array_merge_recursive(): Argument #1 is not an array in /in/ZT4XJ on line 62 Warning: array_merge_recursive(): Argument #1 is not an array in /in/ZT4XJ on line 62 Warning: array_merge_recursive(): Argument #1 is not an array in /in/ZT4XJ on line 62 Warning: array_merge_recursive(): Argument #1 is not an array in /in/ZT4XJ on line 62 Warning: array_merge_recursive(): Argument #1 is not an array in /in/ZT4XJ on line 62 Warning: array_merge_recursive(): Argument #1 is not an array in /in/ZT4XJ on line 62 Warning: array_merge_recursive(): Argument #1 is not an array in /in/ZT4XJ on line 62 Warning: array_merge_recursive(): Argument #1 is not an array in /in/ZT4XJ on line 62 Warning: array_merge_recursive(): Argument #1 is not an array in /in/ZT4XJ on line 62 Warning: array_merge_recursive(): Argument #1 is not an array in /in/ZT4XJ on line 62 Warning: array_merge_recursive(): Argument #1 is not an array in /in/ZT4XJ on line 62 Warning: array_merge_recursive(): Argument #1 is not an array in /in/ZT4XJ on line 62 Warning: array_merge_recursive(): Argument #1 is not an array in /in/ZT4XJ on line 62 Warning: array_merge_recursive(): Argument #1 is not an array in /in/ZT4XJ on line 62 Warning: array_merge_recursive(): Argument #1 is not an array in /in/ZT4XJ on line 62 Warning: array_merge_recursive(): Argument #1 is not an array in /in/ZT4XJ on line 62 Warning: array_merge_recursive(): Argument #1 is not an array in /in/ZT4XJ on line 62 Warning: array_merge_recursive(): Argument #1 is not an array in /in/ZT4XJ on line 62 Warning: array_merge_recursive(): Argument #1 is not an array in /in/ZT4XJ on line 62 Warning: array_merge_recursive(): Argument #1 is not an array in /in/ZT4XJ on line 62 Warning: array_merge_recursive(): Argument #1 is not an array in /in/ZT4XJ on line 62 Warning: array_merge_recursive(): Argument #1 is not an array in /in/ZT4XJ on line 62 Warning: array_merge_recursive(): Argument #1 is not an array in /in/ZT4XJ on line 62 Warning: array_merge_recursive(): Argument #1 is not an array in /in/ZT4XJ on line 62 Warning: array_merge_recursive(): Argument #1 is not an array in /in/ZT4XJ on line 62 Warning: array_merge_recursive(): Argument #1 is not an array in /in/ZT4XJ on line 62 Warning: array_merge_recursive(): Argument #1 is not an array in /in/ZT4XJ on line 62 Warning: array_merge_recursive(): Argument #1 is not an array in /in/ZT4XJ on line 62 Warning: array_merge_recursive(): Argument #1 is not an array in /in/ZT4XJ on line 62 Warning: array_merge_recursive(): Argument #1 is not an array in /in/ZT4XJ on line 62 Warning: array_merge_recursive(): Argument #1 is not an array in /in/ZT4XJ on line 62 Warning: array_merge_recursive(): Argument #1 is not an array in /in/ZT4XJ on line 62 Warning: array_merge_recursive(): Argument #1 is not an array in /in/ZT4XJ on line 62 Warning: array_merge_recursive(): Argument #1 is not an array in /in/ZT4XJ on line 62 Warning: array_merge_recursive(): Argument #1 is not an array in /in/ZT4XJ on line 62 Warning: array_merge_recursive(): Argument #1 is not an array in /in/ZT4XJ on line 62 Warning: array_merge_recursive(): Argument #1 is not an array in /in/ZT4XJ on line 62 Warning: array_merge_recursive(): Argument #1 is not an array in /in/ZT4XJ on line 62 Warning: array_merge_recursive(): Argument #1 is not an array in /in/ZT4XJ on line 62 Warning: array_merge_recursive(): Argument #1 is not an array in /in/ZT4XJ on line 62 Warning: array_merge_recursive(): Argument #1 is not an array in /in/ZT4XJ on line 62
Output for 4.3.0 - 4.4.9
Array ( [0] => Expurgo [Famosos e Etc] => Array ( [0] => Ego [Ego] => Array ( [0] => 40 Graus [40 Graus] => Home [1] => Beleza [Beleza] => Home [2] => Carnaval [Especiais] => Array ( [0] => Avon [1] => Dia das Maes [2] => Lollapalooza [Lollapalooza] => Home [3] => Loreal [4] => Malwee [5] => Natal [6] => Pascoa [7] => Rock in Rio [Rock in Rio] => Home [8] => The Body Shop ) [3] => Gravidez [Gravidez] => Home [4] => Home [5] => Horoscopo [Horoscopo] => Home [6] => Moda [Moda] => Home [7] => Teen [Teen] => Home ) [1] => Home ) [G1] => Array ( [0] => Agronegocios [Agronegocios] => Home [1] => Bem Estar [Bem Estar] => Home [2] => Blogs e Colunas [Blogs e Colunas] => Array ( [0] => Altieres Rohr [1] => Alysson Muotri [2] => Andrea Ramal [3] => Bruno Medina [4] => Cassio Barbosa [5] => Cristina Lobo [6] => Geneton Moraes Neto [7] => Luciano Trigo [8] => Paulo Coelho [9] => Redacao [10] => Ronaldo Prass [11] => Sergio Nogueira [12] => Startup [13] => Thais Heredia [14] => Viver Noronha [15] => Yvonne Maggie [16] => Zeca Camargo ) ) )