problem returning array in a function
Posted: Sun May 25, 2008 10:17 pm
Hey guys,
I have a function the gets some data from a DOM object but I cant seem the put it all in array to return that array object.
I excluded some variables that go before the for loop since they are not relevant to my question. If I print $venueData inside the for loop it works perfect. But if I do the following then I get nothing when printing it.
And I need to be able to loop through the $query object, but it seems to be empty. What can I do here ?
Many thanks!
I have a function the gets some data from a DOM object but I cant seem the put it all in array to return that array object.
Code: Select all
function runQuery()
{
foreach ($venues as $venue)
{
$names = $venue->getElementsByTagName('name');
$contacts = $venue->getElementsByTagName('contact_link');
foreach ($contacts as $contact)
{
$contact = getContact($contact->getAttribute('href'));
$venueItem['contact_info'] = $contact;
}
foreach ($names as $name)
{
$venueItem['name'] = $name->nodeValue;
if($name->getAttribute('href') != NULL)
{
$address = getAddress($name->getAttribute('href'));
}
else
{
$address = getAddress($contact['link']);
}
$venueItem['address_info'] = $address;
}
$venueData['item'] = $venueItem;
}
return $venueData;
}Code: Select all
$query = runQuery();
print_r($query);Many thanks!