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"]; 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 If I understand while ($row = mysqli_fetch_assoc($result) { $media[$row['id']] = $row; } 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 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
Archived
This topic is now archived and is closed to further replies.