Jump to content

Recommended Posts

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

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.