i have a multi dimensional array , about 3 levels,

i need a value from level 3, level 2 has only 1 key but it is a random string of charcters.

ie
$val[-1]['25B98000-12A0-4E40-BB7F-73529DD76B6F']['event_text'];

i need ['event_text'] , what should i substitue the random code for??

i have tried [0], [1] & [-1]

im sure its a simple answer but i've exhausted my references!!

many thanks

    If I understand correctly, maybe:

    $level2 = current($val[array_rand($val)]);
    $event = $level2['event_text'];
    

      thanks,
      i have simplified to

      $level2 = current($val[-1]); 
      				echo $event = $level2['event_text'];

      i dont see why the array_rand function was needed???

        Sorry, I think I interpreted your thread title to mean you wanted a random element from the array.

          no worries, i can see how the title was mis leading!!

          thanks for the "pointer" towards current() !!!

          sorry bad puns!

            Write a Reply...