0

I have a multi-dimensional associative array like this one:

array (size=2)
  'a' => 
    array (size=3)
      'b' => string 'this' (length=4)
      'c' => string 'is' (length=2)
      'd' => string 'a test' (length=6)
  'c' => 
    array (size=4)
      0 => int 1
      1 => int 2
      2 => int 3
      3 => 
        array (size=1)
          'd' => string '123' (length=3)

I try to flatten it to a single-dimensional associative array with the treepath as keys:

array (size=7)
  'a>b' => string 'this' (length=4)
  'a>c' => string 'is' (length=2)
  'a>d' => string 'a test' (length=6)
  'c>0' => string '1' (length=1)
  'c>1' => string '2' (length=1)
  'c>2' => string '3' (length=1)
  'c>3>d' => string '123' (length=3)

See my attempt here: http://codepad.org/MGaBPpZP

ESP32
  • 8,089
  • 2
  • 40
  • 61
  • 1
    top voted answer on linked post in duplicate report above would do this for you. You would just need to change: $result = $result + flatten($value, $prefix . $key . '.'); to $result = $result + flatten($value, $prefix . $key . '>'); – fully stacked geek Jan 28 '16 at 15:31
  • 1
    Yes, duplicate. Thank you - I searched SO quite a time but did not find it. – ESP32 Jan 28 '16 at 15:36

0 Answers0