3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $ar_tree=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", "GE", "GE/Futebol"); function stringToArray($path) { $separator = '/'; $pos = strpos($path, $separator); if ($pos === false) { return array($path); } $key = substr($path, 0, $pos); $path = substr($path, $pos + 1); $result = array( $key => stringToArray($path), ); return $result; } $master_array = array(); foreach ($ar_tree as $lines) { echo $lines . "<br /><br />"; // process each path foreach ($lines as $line) { // split each line by / $struct = stringToArray($line); // merge new path into the output array $master_array = array_merge_recursive($master_array, $struct); } } print_r($master_array);
based on BqlIR
Output for 4.3.0 - 4.3.10, 4.4.0 - 7.2.6
Expurgo<br /><br /> Warning: Invalid argument supplied for foreach() in /in/7Sjg0 on line 78 Famosos e Etc/Ego<br /><br /> Warning: Invalid argument supplied for foreach() in /in/7Sjg0 on line 78 Famosos e Etc/Ego/40 Graus<br /><br /> Warning: Invalid argument supplied for foreach() in /in/7Sjg0 on line 78 Famosos e Etc/Ego/40 Graus/Home<br /><br /> Warning: Invalid argument supplied for foreach() in /in/7Sjg0 on line 78 Famosos e Etc/Ego/Beleza<br /><br /> Warning: Invalid argument supplied for foreach() in /in/7Sjg0 on line 78 Famosos e Etc/Ego/Beleza/Home<br /><br /> Warning: Invalid argument supplied for foreach() in /in/7Sjg0 on line 78 Famosos e Etc/Ego/Carnaval<br /><br /> Warning: Invalid argument supplied for foreach() in /in/7Sjg0 on line 78 Famosos e Etc/Ego/Especiais/Avon<br /><br /> Warning: Invalid argument supplied for foreach() in /in/7Sjg0 on line 78 Famosos e Etc/Ego/Especiais/Dia das Maes<br /><br /> Warning: Invalid argument supplied for foreach() in /in/7Sjg0 on line 78 Famosos e Etc/Ego/Especiais/Lollapalooza<br /><br /> Warning: Invalid argument supplied for foreach() in /in/7Sjg0 on line 78 Famosos e Etc/Ego/Especiais/Lollapalooza/Home<br /><br /> Warning: Invalid argument supplied for foreach() in /in/7Sjg0 on line 78 Famosos e Etc/Ego/Especiais/Loreal<br /><br /> Warning: Invalid argument supplied for foreach() in /in/7Sjg0 on line 78 Famosos e Etc/Ego/Especiais/Malwee<br /><br /> Warning: Invalid argument supplied for foreach() in /in/7Sjg0 on line 78 Famosos e Etc/Ego/Especiais/Natal<br /><br /> Warning: Invalid argument supplied for foreach() in /in/7Sjg0 on line 78 Famosos e Etc/Ego/Especiais/Pascoa<br /><br /> Warning: Invalid argument supplied for foreach() in /in/7Sjg0 on line 78 Famosos e Etc/Ego/Especiais/Rock in Rio<br /><br /> Warning: Invalid argument supplied for foreach() in /in/7Sjg0 on line 78 Famosos e Etc/Ego/Especiais/Rock in Rio/Home<br /><br /> Warning: Invalid argument supplied for foreach() in /in/7Sjg0 on line 78 Famosos e Etc/Ego/Especiais/The Body Shop<br /><br /> Warning: Invalid argument supplied for foreach() in /in/7Sjg0 on line 78 Famosos e Etc/Ego/Gravidez<br /><br /> Warning: Invalid argument supplied for foreach() in /in/7Sjg0 on line 78 Famosos e Etc/Ego/Gravidez/Home<br /><br /> Warning: Invalid argument supplied for foreach() in /in/7Sjg0 on line 78 Famosos e Etc/Ego/Home<br /><br /> Warning: Invalid argument supplied for foreach() in /in/7Sjg0 on line 78 Famosos e Etc/Ego/Horoscopo<br /><br /> Warning: Invalid argument supplied for foreach() in /in/7Sjg0 on line 78 Famosos e Etc/Ego/Horoscopo/Home<br /><br /> Warning: Invalid argument supplied for foreach() in /in/7Sjg0 on line 78 Famosos e Etc/Ego/Moda<br /><br /> Warning: Invalid argument supplied for foreach() in /in/7Sjg0 on line 78 Famosos e Etc/Ego/Moda/Home<br /><br /> Warning: Invalid argument supplied for foreach() in /in/7Sjg0 on line 78 Famosos e Etc/Ego/Teen<br /><br /> Warning: Invalid argument supplied for foreach() in /in/7Sjg0 on line 78 Famosos e Etc/Ego/Teen/Home<br /><br /> Warning: Invalid argument supplied for foreach() in /in/7Sjg0 on line 78 Famosos e Etc/Home<br /><br /> Warning: Invalid argument supplied for foreach() in /in/7Sjg0 on line 78 G1/Agronegocios<br /><br /> Warning: Invalid argument supplied for foreach() in /in/7Sjg0 on line 78 G1/Agronegocios/Home<br /><br /> Warning: Invalid argument supplied for foreach() in /in/7Sjg0 on line 78 G1/Bem Estar<br /><br /> Warning: Invalid argument supplied for foreach() in /in/7Sjg0 on line 78 G1/Bem Estar/Home<br /><br /> Warning: Invalid argument supplied for foreach() in /in/7Sjg0 on line 78 G1/Blogs e Colunas<br /><br /> Warning: Invalid argument supplied for foreach() in /in/7Sjg0 on line 78 G1/Blogs e Colunas/Altieres Rohr<br /><br /> Warning: Invalid argument supplied for foreach() in /in/7Sjg0 on line 78 G1/Blogs e Colunas/Alysson Muotri<br /><br /> Warning: Invalid argument supplied for foreach() in /in/7Sjg0 on line 78 G1/Blogs e Colunas/Andrea Ramal<br /><br /> Warning: Invalid argument supplied for foreach() in /in/7Sjg0 on line 78 G1/Blogs e Colunas/Bruno Medina<br /><br /> Warning: Invalid argument supplied for foreach() in /in/7Sjg0 on line 78 G1/Blogs e Colunas/Cassio Barbosa<br /><br /> Warning: Invalid argument supplied for foreach() in /in/7Sjg0 on line 78 G1/Blogs e Colunas/Cristina Lobo<br /><br /> Warning: Invalid argument supplied for foreach() in /in/7Sjg0 on line 78 G1/Blogs e Colunas/Geneton Moraes Neto<br /><br /> Warning: Invalid argument supplied for foreach() in /in/7Sjg0 on line 78 G1/Blogs e Colunas/Luciano Trigo<br /><br /> Warning: Invalid argument supplied for foreach() in /in/7Sjg0 on line 78 G1/Blogs e Colunas/Paulo Coelho<br /><br /> Warning: Invalid argument supplied for foreach() in /in/7Sjg0 on line 78 G1/Blogs e Colunas/Redacao<br /><br /> Warning: Invalid argument supplied for foreach() in /in/7Sjg0 on line 78 G1/Blogs e Colunas/Ronaldo Prass<br /><br /> Warning: Invalid argument supplied for foreach() in /in/7Sjg0 on line 78 G1/Blogs e Colunas/Sergio Nogueira<br /><br /> Warning: Invalid argument supplied for foreach() in /in/7Sjg0 on line 78 G1/Blogs e Colunas/Startup<br /><br /> Warning: Invalid argument supplied for foreach() in /in/7Sjg0 on line 78 G1/Blogs e Colunas/Thais Heredia<br /><br /> Warning: Invalid argument supplied for foreach() in /in/7Sjg0 on line 78 G1/Blogs e Colunas/Viver Noronha<br /><br /> Warning: Invalid argument supplied for foreach() in /in/7Sjg0 on line 78 G1/Blogs e Colunas/Yvonne Maggie<br /><br /> Warning: Invalid argument supplied for foreach() in /in/7Sjg0 on line 78 G1/Blogs e Colunas/Zeca Camargo<br /><br /> Warning: Invalid argument supplied for foreach() in /in/7Sjg0 on line 78 GE<br /><br /> Warning: Invalid argument supplied for foreach() in /in/7Sjg0 on line 78 GE/Futebol<br /><br /> Warning: Invalid argument supplied for foreach() in /in/7Sjg0 on line 78 Array ( )
Output for 4.3.11
Expurgo<br /><br />Famosos e Etc/Ego<br /><br />Famosos e Etc/Ego/40 Graus<br /><br />Famosos e Etc/Ego/40 Graus/Home<br /><br />Famosos e Etc/Ego/Beleza<br /><br />Famosos e Etc/Ego/Beleza/Home<br /><br />Famosos e Etc/Ego/Carnaval<br /><br />Famosos e Etc/Ego/Especiais/Avon<br /><br />Famosos e Etc/Ego/Especiais/Dia das Maes<br /><br />Famosos e Etc/Ego/Especiais/Lollapalooza<br /><br />Famosos e Etc/Ego/Especiais/Lollapalooza/Home<br /><br />Famosos e Etc/Ego/Especiais/Loreal<br /><br />Famosos e Etc/Ego/Especiais/Malwee<br /><br />Famosos e Etc/Ego/Especiais/Natal<br /><br />Famosos e Etc/Ego/Especiais/Pascoa<br /><br />Famosos e Etc/Ego/Especiais/Rock in Rio<br /><br />Famosos e Etc/Ego/Especiais/Rock in Rio/Home<br /><br />Famosos e Etc/Ego/Especiais/The Body Shop<br /><br />Famosos e Etc/Ego/Gravidez<br /><br />Famosos e Etc/Ego/Gravidez/Home<br /><br />Famosos e Etc/Ego/Home<br /><br />Famosos e Etc/Ego/Horoscopo<br /><br />Famosos e Etc/Ego/Horoscopo/Home<br /><br />Famosos e Etc/Ego/Moda<br /><br />Famosos e Etc/Ego/Moda/Home<br /><br />Famosos e Etc/Ego/Teen<br /><br />Famosos e Etc/Ego/Teen/Home<br /><br />Famosos e Etc/Home<br /><br />G1/Agronegocios<br /><br />G1/Agronegocios/Home<br /><br />G1/Bem Estar<br /><br />G1/Bem Estar/Home<br /><br />G1/Blogs e Colunas<br /><br />G1/Blogs e Colunas/Altieres Rohr<br /><br />G1/Blogs e Colunas/Alysson Muotri<br /><br />G1/Blogs e Colunas/Andrea Ramal<br /><br />G1/Blogs e Colunas/Bruno Medina<br /><br />G1/Blogs e Colunas/Cassio Barbosa<br /><br />G1/Blogs e Colunas/Cristina Lobo<br /><br />G1/Blogs e Colunas/Geneton Moraes Neto<br /><br />G1/Blogs e Colunas/Luciano Trigo<br /><br />G1/Blogs e Colunas/Paulo Coelho<br /><br />G1/Blogs e Colunas/Redacao<br /><br />G1/Blogs e Colunas/Ronaldo Prass<br /><br />G1/Blogs e Colunas/Sergio Nogueira<br /><br />G1/Blogs e Colunas/Startup<br /><br />G1/Blogs e Colunas/Thais Heredia<br /><br />G1/Blogs e Colunas/Viver Noronha<br /><br />G1/Blogs e Colunas/Yvonne Maggie<br /><br />G1/Blogs e Colunas/Zeca Camargo<br /><br />GE<br /><br />GE/Futebol<br /><br />Array ( )