genzedu777 Posted May 23, 2010 Share Posted May 23, 2010 Hi, I need some help in understanding this coding $data=mysqli_query ($dbc,$query); $topicIDs = array(); while ($row = mysqli_fetch_array($data)) { array_push($topicIDs, $row['topic_id']); For $topicIDs = array(), my understanding is, it is meant to clear or empty any arrays that is in the $topicIDs variable? Am I right? array_push($topicIDs, $row['topic_id']);. I am really confused in this portion. Is $row['topic_id'] value stored in $topicIDs? Thanks, Wilson Link to comment https://forums.phpfreaks.com/topic/202623-array_push-queries/ Share on other sites More sharing options...
DavidAM Posted May 23, 2010 Share Posted May 23, 2010 For $topicIDs = array(), my understanding is, it is meant to clear or empty any arrays that is in the $topicIDs variable? Am I right? Pretty much. It assigns an empty array to $topicIDs. If anything was there before (whether an array or a scalar) it is lost. If it did not exist before, it will now. array_push($topicIDs, $row['topic_id']);. I am really confused in this portion. Is $row['topic_id'] value stored in $topicIDs? That adds the value in $row['topic_id'] on to the end of the array ($topicIDs). It is the same as $topicIDs[] = $row['topic_id'] Link to comment https://forums.phpfreaks.com/topic/202623-array_push-queries/#findComment-1062120 Share on other sites More sharing options...
genzedu777 Posted May 23, 2010 Author Share Posted May 23, 2010 Thanks David, thanks for confirming my understanding Link to comment https://forums.phpfreaks.com/topic/202623-array_push-queries/#findComment-1062130 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.