note 110574 added to simplexmlelement.attributes

From: Date: Thu, 08 Nov 2012 17:21:23 +0000
Subject: note 110574 added to simplexmlelement.attributes
Groups: php.notes 
Request: Send a blank email to php-notes+get-191812@lists.php.net to get a copy of this message
Tip to get a real array of all attributes of a node (not SimpleXML's object acting like an array) <?php //- $node is a SimpleXMLElement object $atts_object = $node->attributes(); //- get all attributes, this is not a real array $atts_array = (array) $atts_object; //- typecast to an array //- grab the value of '@attributes' key, which contains the array your after $atts_array = $atts_array['@attributes']; var_dump($atts_object); //- outputs object(SimpleXMLElement)[19] //- public '@attributes' => ... var_dump($atts_array); //- outputs array (size=11) ... ?> Hope this helps! ---- Server IP: 87.124.126.49 Probable Submitter: 86.2.247.236 ---- Manual Page -- http://www.php.net/manual/en/simplexmlelement.attributes.php Edit -- https://master.php.net/note/edit/110574 Del: integrated -- https://master.php.net/note/delete/110574/integrated Del: useless -- https://master.php.net/note/delete/110574/useless Del: bad code -- https://master.php.net/note/delete/110574/bad+code Del: spam -- https://master.php.net/note/delete/110574/spam Del: non-english -- https://master.php.net/note/delete/110574/non-english Del: in docs -- https://master.php.net/note/delete/110574/in+docs Del: other reasons-- https://master.php.net/note/delete/110574 Reject -- https://master.php.net/note/reject/110574 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#191812) next »