I am trying to create a single events PHP array from 3 different arrays that are created from an xml file. The arrays I currently have are:
Venues - Comes from the venuesList xml node
Titles - Comes from the titleList xml node
Events - Comes from the eventList xml node
The eventList->event xml node has attributes for venueID and titleID. I subsequently need to create an array with events, merging the correct venue and title data with the correct event using the venueID and titleID attributes.
The information I am currently pulling in from each array is as follows:
Venues - has venueID attribute
- venueName
- categories
- venueAddress
- disabledAccess
- website
Titles - has titleID attribute
- categories
- website
- description
Events - has titleID and venueID attributes
- eventName
- venueID
- titleID
I require an array with the following:
Events Array
- eventName
- venueName
- categories
- venueAddress
- disabledAccess
- website
- categories
- website
- description
My code is as follows:
$value) { $i++;
if($value==$date.'0822_ope_full.xml') {
$xml=simplexml_load_file('ftp://southwark:jqA3%Rpn@ftp.howden.press.net/'.$value.'');
echo "Venues";
$venuesarray = array();
foreach($xml->venueList->venue as $venue) {
$venuearray = array();
foreach($venue as $key => $value) {
$venuearray[(string)$key] = (string)$value;
$venuearray['venueID'] = (string)$venue['venueID'];
}
$venuesarray['venueList'][] = $venuearray;
echo 'Venue Name: '.$venue->venueName.'';
echo 'Venue Address: '.$venue->venueAddress->streetName.', '.$venue->venueAddress->district.', '.$venue->venueAddress->town.', '.$venue->venueAddress->county.', '.$venue->venueAddress->postcode.'';
echo 'Credit Card Tel: '.$venue->creditCardTel.'';
echo 'Disabled Access: '.$venue->disabledAccess.'';
echo 'Phone: '.$venue->phone->dialcode.' '.$venue->phone->phonenumber.'';
echo 'Transport: '.$venue->venueTransport.'';
echo 'Email: '.$venue->email.'';
echo '';
}
echo "Titles";
$titlesarray = array();
foreach($xml->titleList->title as $title) {
$titlearray = array();
foreach($title as $key => $value) {
$titlearray[(string)$key] = (string)$value;
$titlearray['titleID'] = (string)$title['titleID'];
}
$titlesarray['titleList'][] = $titlearray;
echo 'Title: '.$title->titleName.'';
echo 'Categories: ';
foreach ($title->categories->category as $cat) {
echo $cat['name'].', ';
} echo '';
echo 'Website: '.$title->website.'';
echo 'Description: '.$title->description['standard'].'';
echo "";
}
echo "Events";
$eventsarray = array();
foreach($xml->eventList->event as $event) {
$eventarray = array();
foreach($event as $key => $value) {
$eventarray[(string)$key] = (string)$value;
$eventarray['eventID'] = (string)$event['eventID'];
$eventarray['venueID'] = (string)$event['venueID'];
$eventarray['titleID'] = (string)$event['titleID'];
}
$eventsarray['eventList'][] = $eventarray;
echo 'Event: '.$event->eventName.'';
echo 'Title ID: '.$eventarray['titleID'].'';
echo 'Venue ID: '.$eventarray['venueID'].'';
echo "";
}
}
}
ftp_close($ftp_conn);
?>
What I have tried:
I have tried merging the arrays but this doesn't give me the required outcome