hansford Posted March 26, 2011 Share Posted March 26, 2011 Hi people I need a way to loop through an array where $imgid is some random number assigned to each array element and there are 4 fields id, url, tnurl, caption per array element. I need to extract these 4 fields in the same loop iteration. Thanks $_SESSION['imagegallery'][$imgid]['id']; $_SESSION['imagegallery'][$imgid]['url']; $_SESSION['imagegallery'][$imgid]['tnurl']; $_SESSION['imagegallery'][$imgid]['caption']; example: $_SESSION['imagegallery'][347]['id']; $_SESSION['imagegallery'][347]['url']; $_SESSION['imagegallery'][347]['tnurl']; $_SESSION['imagegallery'][347]['caption']; $_SESSION['imagegallery'][892]['id']; $_SESSION['imagegallery'][892]['url']; $_SESSION['imagegallery'][892]['tnurl']; $_SESSION['imagegallery'][892]['caption']; Link to comment https://forums.phpfreaks.com/topic/231766-multi-field-array/ Share on other sites More sharing options...
PFMaBiSmAd Posted March 26, 2011 Share Posted March 26, 2011 $_SESSION['imagegallery'] is an array of arrays. You can use array functions to iterate over it and get the key/inner array - foreach($_SESSION['imagegallery'] as $key=>$array){ echo "Key: $key, ID: {$array['id']}, URL: {$array['url']}, TNURL: {$array['tnurl']}, Caption: {$array['caption']}<br />"; } Link to comment https://forums.phpfreaks.com/topic/231766-multi-field-array/#findComment-1192477 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.