Jump to content

[SOLVED] Returning multiple variables from a function


Recommended Posts

array_fill is NOT the correct function. Incrementally assigning values to an array is actually quite easy. A statement like this automatically adds a value to the next available index:$arr[] = $val;Put that in a loop and $arr will fill up will the changing values of $val. Do you want to return the whole row or just the value of $row['fieldname'] ? Either way, the plan is the same:

while($row = mysql_fetch_assoc($result))	{		$arr[] = $row['fieldname'];	}return($arr);// ORwhile($row = mysql_fetch_assoc($result))	{		$arr[] = $row;	}return($arr);

Link to post
Share on other sites

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.   Paste as plain text instead

  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.

Loading...
×
×
  • Create New...