Re: is_array() doesn't work on DOM properties?

From: Date: Tue, 26 Jul 2005 18:12:02 +0000
Subject: Re: is_array() doesn't work on DOM properties?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-219372@lists.php.net to get a copy of this message
This is with simplexml_load_file(). Using an empty() check instead of is_array() does the trick (though - note to php hackers - I think is_array() SHOULD work). John --- Jochem Maas <jochem@iamjochem.com> wrote: > John Smith wrote: > > I'm trying to avoid error messages while iterating > > over DOM properties. e.g. > > > > > > if(is_array($dom->stuff->props)) { > > maybe you can get roudn the problem by saying?: > > if($dom->stuff->props) { > > or?: > > if(!empty($dom->stuff->props)) { > > > foreach($dom->stuff->props as $prop) { > > ... > > } > > } > > > > It works without the is_array() check, but not > with > > my guess is you'll find that $dom->stuff->props is > an object > which overloads the array accessor stuff... > basically it's implementing Iterator (or some other > SPL Interface) > > hard to tell though because you don't mention which > DOM > related extension you are using. > > > it. I've done var_dumps and $dom->stuff->props is > > indeed an array. I've also tried using an > intermediate > > variable ($stuff=$dom->stuff) then checking that, > but > > that doesn't work either). > > > > John > > > > > > > > > ____________________________________________________ > > Start your day with Yahoo! - make it your home > page > > http://www.yahoo.com/r/hs > > > > > > __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com

« previous php.general (#219372) next »