x2i Posted May 5, 2009 Share Posted May 5, 2009 Hi, I'm experiencing a little problem picking out specific values in an array that I have - I have used var_dump to out put the following but I cannot pick out the specific items I want: array(1) { [0]=> array(9) { ["ARTIST_MBID"]=> string(36) "329f95db-f02e-40bf-a5f7-0dea11529ce3" ["ARTIST"]=> string(13) "Enter Shikari" ["NAME"]=> string(11) "Juggernauts" ["MBID"]=> string(0) "" ["ALBUM_MBID"]=> string(0) "" ["ALBUM"]=> string(0) "" ["URL"]=> string(52) "http://www.last.fm/music/Enter+Shikari/_/Juggernauts" ["DATE_UTS"]=> string(10) "1240718080" ["DATE"]=> string(18) "26 Apr 2009, 03:54" } } I want to be able to get say the artist name and song name as strings. I have tried using foreach to no avail and because the arrays are embedded within one another I don't quite know how to do it, could anyone help at all? Thanks in advance... Quote Link to comment https://forums.phpfreaks.com/topic/156980-solved-help-singling-out-items-in-an-array/ Share on other sites More sharing options...
Ken2k7 Posted May 5, 2009 Share Posted May 5, 2009 Well did you know that your array has an inner array? You may want to use array_pop or array[0] on it first. Quote Link to comment https://forums.phpfreaks.com/topic/156980-solved-help-singling-out-items-in-an-array/#findComment-826898 Share on other sites More sharing options...
Zhadus Posted May 5, 2009 Share Posted May 5, 2009 Like this? It looks like you have a multidimensional array. <?php echo 'Artist: ' . $arrayVariable[0]['ARTIST'] . '<br />'; echo 'Song: ' . $arrayVariable[0]['NAME'] . '<br />'; ?> Quote Link to comment https://forums.phpfreaks.com/topic/156980-solved-help-singling-out-items-in-an-array/#findComment-826899 Share on other sites More sharing options...
allworknoplay Posted May 5, 2009 Share Posted May 5, 2009 As the others have said, it looks like a multi-dimensional array. How are you creating the array in the first place? It looks like you don't need to have that extra array in there... Quote Link to comment https://forums.phpfreaks.com/topic/156980-solved-help-singling-out-items-in-an-array/#findComment-826901 Share on other sites More sharing options...
x2i Posted May 5, 2009 Author Share Posted May 5, 2009 I used the following class to output the array: http://lauris.night.lt/forge/easy_scrobbler/ I'll give your solutions a shot, thanks EDIT: It worked thankyou guys Quote Link to comment https://forums.phpfreaks.com/topic/156980-solved-help-singling-out-items-in-an-array/#findComment-826976 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.