OK so I posted this question earlier and it remains unanswered. I am grateful for the attempts though.
Foreach loop not outputting arrays as expected
I have tried to narrow this down. I need to know if the array created from a string using explode is in some way different to an array specified by $foo = array(.....). Take this code
$category_array = array('Pulmonary sarcoidosis', 'Acute critical care', 'Congenital lung disease');
foreach($category_array as $category){
$result = Thread_category::find_all_by_category($category);
foreach ($result as $result_array){
echo $result_array->thread_id;
echo "<br/>";
}
}
?>
Yields:
145 146 149 151
144 148 150 151
145 147 148 149 151
Which is correct. But an array created as follows...
$category_array = explode(",", $thread->category);
Which is when outputed gives
Array ( [0] => Pulmonary sarcoidosis [1] => Acute critical care [2] => Congenital lung disease )
But when going through the foreach loop gives...
145 146 149 151
It halts as after the first loop......
No idea why and been on this for hours outputting everything.....
I understand there is code in here I haven't explained but I think the problem has to be occuring at the explode level....please help!