Hello everyone. I have loaded 2 XML files which have children elements with attributes. Both work correctly, they are tested. The problem is that i am trying to compare an attribute from the first XML with one from the other and it fails even though both files have the same values in a given attribute. More specifically I am loading <option> tags for a <select> tag from this:
Where is $this_schoolcat set? Are you sure it has the expected value when you use it in the comparison?
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in Nation
foreach ($institutions as $institution) { if ($institution['id']==$id) { $current_uni = $institution; } } $this_schoolcat = $current_uni['schoolcat'];
Now $current_uni is definately correct, since i have made tons of $current_uni['whatever_i_want'] calls in this file in other places. It is actually a form that gets an id, searches the xml file of universities and fills the form with its data for editing. On the point where I have the problem, I just can't get the university category as selected on the list for the university I've called in the form
All I can suggest at this point is to add some debug code within that foreach loop, echoing or var_dump()-ing he variables involved and seeing which ones (if any) are not set as expected. As far as I can see the logic looks OK, so my guess is something does not have the value you think it should. Locating that will probably point you to the source of the problem.
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in Nation
Hmmmm You know what? I think it just might be blank characters (which do not exist in the actual XML but maybe the parsing functions do something fishy). How do I strip spaces from the left and right of a string?
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in Nation
Bookmarks