xref: /PHP-8.0/ext/simplexml/tests/022.phpt (revision f8d79582)
1--TEST--
2SimpleXML: Attributes inside foreach
3--SKIPIF--
4<?php if (!extension_loaded("simplexml")) print "skip"; ?>
5--FILE--
6<?php
7
8$xml =<<<EOF
9<?xml version='1.0'?>
10<pres><content><file glob="slide_*.xml"/></content></pres>
11EOF;
12
13$sxe = simplexml_load_string($xml);
14
15echo "===CONTENT===\n";
16var_dump($sxe->content);
17
18echo "===FILE===\n";
19var_dump($sxe->content->file);
20
21echo "===FOREACH===\n";
22foreach($sxe->content->file as $file)
23{
24    var_dump($file);
25    var_dump($file['glob']);
26}
27
28?>
29--EXPECTF--
30===CONTENT===
31object(SimpleXMLElement)#%d (1) {
32  ["file"]=>
33  object(SimpleXMLElement)#%d (1) {
34    ["@attributes"]=>
35    array(1) {
36      ["glob"]=>
37      string(11) "slide_*.xml"
38    }
39  }
40}
41===FILE===
42object(SimpleXMLElement)#%d (1) {
43  ["@attributes"]=>
44  array(1) {
45    ["glob"]=>
46    string(11) "slide_*.xml"
47  }
48}
49===FOREACH===
50object(SimpleXMLElement)#%d (1) {
51  ["@attributes"]=>
52  array(1) {
53    ["glob"]=>
54    string(11) "slide_*.xml"
55  }
56}
57object(SimpleXMLElement)#%d (1) {
58  [0]=>
59  string(11) "slide_*.xml"
60}
61