|$jobs = simplexml_load_file('jobfeed.xml');|
|function output_list($jobs = array())|
|$data = array();|
|foreach($jobs->xpath('/jobs/job') as $job_details)|
|$category = $job_details->department;|
|$title = $job_details->title;|
|$url = $job_details->url;|
|$data[$category] = array();|
|$data[$category] = '<li>Category: '.$category.'<br>Title: '.$title.'<br>URL: '.$url.'</li>';|
|foreach($data as $category => $items)|
|$data[$category] = '<li><ul>'.implode('', $items).'</ul></li>';|
|return '<ul>'.implode('', $data).'</ul>';|
I only made 2 modifications to the code you wrote:
But I don't see how either of those changes would cause errors.
I actually get several EE PHP errors:
lines 16 & 19:
This comment has been minimized.
This comment has been minimized.Show comment Hide comment
Add right above line 14, var_dump($data);exit();
That will output the $data array and see why there is an error. My guess is the $category variable is NULL or not set correctly and is possible a bad index. You could also do a var_dump($category);exit(); above live 14 to see what the category value is. Ensure that it actually has some value and those errors should do away. You are really close. My logis is 100% correct, it's just conflicts with your data and my code.
Both would imply that there is no data being returned for the
The categories are output perfectly fine.