I’m trying to access information in a previously created multidimensional array. Using print_r(), I’ve got this info about the array(which I’ve spaced out myself, and may’ve done so oddly…):
Array (
[Video] => Array (
[0] => a:3:{
s:19:"upload_video_submit";
s:0:"";
s:12:"upload_video";
s:26:"this-is-the-video-link.mp4";
s:12:"video_length";
s:8:"10-10-10";
}
)
[_edit_last] => Array ( [0] => 1 )
[_edit_lock] => Array ( [0] => 1288823181 )
[key] => Array (
[0] => a:4:{
s:4:"game";
a:2:{
i:0;
s:4:"9man";
i:1;
s:5:"18man";
}
s:4:"type";
a:1:{
i:0;
s:7:"Lecture";
}
s:5:"coach";
a:1:{
i:0;
s:8:"msusyr24";
}
s:12:"upload-video";
s:70:"http://localhost:8888/pocarr/wp-content/uploads/2010/09/BigCupcake.flv";
}
)
)
I’d like to access the arrays inside the key array, such something like
echo $key_array[key][0]["type"] to get “Lecture”, or echo $key_array[Video][0]["upload_video"] to get “this-is-the-videolink.mp4” … but I’m totally baffled by the “:”s
The most I can figure is that “s” = a string, and the number is the number of characters (similarly “a”= an array).
Any ideas how to get that info out of the array?
UPDATE:
I ended up using:
$new = unserialize($keys_array[Video][0]);
echo $new[upload_video];
Thanks for you help!
Looks like some of your array values have been serialized. Check out PHP’s unserialize function. Doing so will allow you to access the array elements as you describe.
For example: