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

2005-07-26 Thread John Smith

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 [EMAIL PROTECTED] 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 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



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

2005-07-26 Thread Jochem Maas

John Smith wrote:

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).


ah simplexml, in that case is_array() shouldn't and won't
work because it's 'all' objects (although I can understand why it seems
like it should work!) - but the objects allow array(-like) iteration
of contained elements.

read this again very carefully:
http://be2.php.net/simplexml

note also that even values are actually objects that implement
the __toString() interface (although I'm not sure that is the
correct way to explain/name it) where by the object is automatically
cast to a string in a sensible way when used with echo/print ...
as the exmaples on the simplexml page show you have to cast manually
if you want to do other things with the string representation (like
using the actually value of the object as the test value of a switch
block.

here is some more reading material:
http://www.onlamp.com/pub/a/php/2004/01/15/simplexml.html

good luck



John


--- Jochem Maas [EMAIL PROTECTED] 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 



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



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

2005-07-25 Thread Jochem Maas

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 
 



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] is_array() doesn't work on DOM properties?

2005-07-24 Thread John Smith
I'm trying to avoid error messages while iterating
over DOM properties. e.g.

if(is_array($dom-stuff-props)) {
  foreach($dom-stuff-props as $prop) {
...
  }
}

It works without the is_array() check, but not with
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 
 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php