An employee An employee - 1 year ago 152
PHP Question

php SimpleXML check if a child exists

might exist but
might not exist. How do I check it?

Answer Source
if($A->b->c != null) //c exists

If c does not exist, its value will be null (or, to be more precise, it will have no value). Note, however, that for this to work, both A and b need to not be null. Otherwise, PHP will throw an error (I think).

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download