fork download
  1. <?php
  2.  
  3. $array = [
  4. "Apartamento" => [ "Characteristics" => [
  5. "external_area"=>
  6. [
  7. 0=> "varanda",
  8. 1=> "lavanderia",
  9. 2=> "piscina",
  10. 3=> "muros",
  11. 4=> "area_serviço"
  12. ],
  13. "bedroom"=>
  14. [
  15. 0=> "piso_frio",
  16. 1=> "alvenaria",
  17. 2=> "azulejo_teto",
  18. 3=> "massa_corrida"
  19. ]
  20. ]
  21. ],
  22. "Casa" => [ "Characteristics" => [
  23.  
  24. "internal_area"=>
  25. [
  26. 0=> "mesa de madeira",
  27. 1=> "area"
  28. ],
  29. "options"=>
  30. [
  31. 0=> "2 andares",
  32. 1=> "banheiro externo",
  33. ]
  34. ]
  35. ]];
  36.  
  37.  
  38. array_walk_recursive($array, function ($item, $key)
  39. {
  40. global $Characeristics;
  41. if (! is_array( $item ) )
  42. $Characeristics[] = $item;
  43. });
  44.  
  45. $result = array( "Characeristics" => $Characeristics );
  46.  
  47. var_dump($result);
Success #stdin #stdout 0.01s 52488KB
stdin
Standard input is empty
stdout
array(1) {
  ["Characeristics"]=>
  array(13) {
    [0]=>
    string(7) "varanda"
    [1]=>
    string(10) "lavanderia"
    [2]=>
    string(7) "piscina"
    [3]=>
    string(5) "muros"
    [4]=>
    string(13) "area_serviço"
    [5]=>
    string(9) "piso_frio"
    [6]=>
    string(9) "alvenaria"
    [7]=>
    string(12) "azulejo_teto"
    [8]=>
    string(13) "massa_corrida"
    [9]=>
    string(15) "mesa de madeira"
    [10]=>
    string(4) "area"
    [11]=>
    string(9) "2 andares"
    [12]=>
    string(16) "banheiro externo"
  }
}