Jump to content

array in loop help


MDanz

Recommended Posts

i have an array in the loop but it isn't building up with results.  i want it to check if the array exists, if not then create the array. Then in next loop it pushes a new value into the array.  Below isn't working?...

 


while($row=mysql_fetch_assoc($get));
{
$key = $row['keyword'];

$scope= $_SESSION['scope'];


		if (!is_array($scope)) {

		$scopenew = array($key);
		$_SESSION['scope'] = $scopenew;

                } else {

		$scopenew = array_push($scope, $key);
			$_SESSION['scope'] = $scopenew;	

}


}

Link to comment
Share on other sites

Are you wanting to add all the keywords returned from your query into the $_SESSION['scope'] array? If so all you need to do is

while($row = mysql_fetch_assoc($get));
{
    $_SESSION['scope'][] = $row['keyword'];
}

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.