Posted By

iloveitaly on 07/20/09


Tagged

attributes array xml simple set add easy quickly


Versions (?)

SimpleXML Set Attributes


 / Published in: PHP
 

Convenience function to set a SimpleXMLElement's attributes quickly.

  1. function set_simplexml_attributes($element, $attributes) {
  2. foreach($attributes as $key => $value) {
  3. $element->addAttribute($key, $value);
  4. }
  5. }
  6.  
  7. // ex:
  8. set_simplexml_attributes($categoryElement, array(
  9. "id" => "1",
  10. "enabled" => "true",
  11. "iconUrl" => $this->thinger,
  12. "tooltip" => "popups/study.swf"
  13. ));

Report this snippet  

You need to login to post a comment.