note 58825 rejected from ref.simplexml by nlopess
| From: | nlopess@php.net | Date: | Thu, 17 Nov 2005 09:12:55 +0000 |
| Subject: | note 58825 rejected from ref.simplexml by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-98689@lists.php.net to get a copy of this message | ||
Note Submitter: traveus at yahoo dot com
----
Is it possible to use a variable as the index of the current element of the array, like below ?
users.xml file:
<?xml version='1.0' standalone='yes' ?>
<users>
<user>
<username>user1</username>
</user>
<user>
<username>user2</username>
</user>
</users>
PHP code:
simplexml_load_file("users.xml");
It doesn't work when I try to use "$node_number" which is 1 or 2:
$user_from_xml=$xml->user[$node_number]->username;
thanx