Stuart_Westgate Posted May 27, 2013 Share Posted May 27, 2013 How do I add this associate array: $media[$row["id"]]['cameraPicture'] = $row["cameraPicture"]; $media[$row["id"]]['photoAlbum'] = $row["photoAlbum"]; $media[$row["id"]]['videoData'] = $row["videoData"]; $media[$row["id"]]['audioData'] = $row["audioData"]; $media[$row["id"]]['textMessage'] = $row["textMessage"]; $media[$row["id"]]['callData'] = $row["callData"]; $media[$row["id"]]['activityData'] = $row["activityData"]; $media[$row["id"]]['latitudePos'] = $row["latitudePos"]; $media[$row["id"]]['longitudePos'] = $row["longitudePos"]; $media[$row["id"]]['currentDate'] = $row["currentDate"]; $media[$row["id"]]['currentTime'] = $row["currentTime"]; to this associate array? $media1[$row["id"]]['cameraPicture'] = $row["cameraPicture"]; $media1[$row["id"]]['photoAlbum'] = $row["photoAlbum"]; $media1[$row["id"]]['videoData'] = $row["videoData"]; $media1[$row["id"]]['audioData'] = $row["audioData"]; $media1[$row["id"]]['textMessage'] = $row["textMessage"]; $media1[$row["id"]]['callData'] = $row["callData"]; $media1[$row["id"]]['activityData'] = $row["activityData"]; $media1[$row["id"]]['latitudePos'] = $row["latitudePos"]; $media1[$row["id"]]['longitudePos'] = $row["longitudePos"]; $media1[$row["id"]]['currentDate'] = $row["currentDate"]; $media1[$row["id"]]['currentTime'] = $row["currentTime"]; Quote Link to comment https://forums.phpfreaks.com/topic/278444-how-do-i-add-to-an-associate-array-to-a-associate-array/ Share on other sites More sharing options...
Barand Posted May 27, 2013 Share Posted May 27, 2013 (edited) If I understand while ($row = mysqli_fetch_assoc($result) { $media[$row['id']] = $row; } Edited May 27, 2013 by Barand Quote Link to comment https://forums.phpfreaks.com/topic/278444-how-do-i-add-to-an-associate-array-to-a-associate-array/#findComment-1432586 Share on other sites More sharing options...
DavidAM Posted May 27, 2013 Share Posted May 27, 2013 Barand's answer is probably the best. Put the data in a single array when you collect it. If they are coming from different places, and that is not possible, have a look at array_merge Quote Link to comment https://forums.phpfreaks.com/topic/278444-how-do-i-add-to-an-associate-array-to-a-associate-array/#findComment-1432597 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.