Iterating zend_config_xml with only 1 child node?

MooslessC

New Member
I have a basic zend_config_xml instance that stores some inventory information such as which products are on replenishment (replenish_departments) vs which products can't be reordered (fashion_departments). (fyi our products are classified into departments, each department has a unique alpha code)My xml looks similar to:\[code\]<inventory> <settings> <allow_backorders>1</allow_backorders> <replenish_departments> <department>M</department> </replenish_departments> <fashion_departments> <department>MF</department> <department>MS</department> </fashion_departments> </settings></inventory>\[/code\]What I need to be able to do is quickly tell if a given department code is in replenish or fashion. What I was trying was simple (or so I thought):\[code\]foreach ($inv_settings->replenish_departments as $replenish_deptcode) { if ($given_deptcode == $replenish_deptcode) return true;}\[/code\]However, what I discovered was that when there is a single child node, you cannot iterate through it. In other words, this code words for fashion_departments, but not replenish_departments.What's the trick here?EDIT: I've discovered that if I typecast $inv_settings as an array inside of the foreach, I am able to iterate without an error. For now, this is the method I'm using, but I'm still open to a better fix.
 
Back
Top