022.phpt 1.0 KB

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