Changes between Initial Version and Version 1 of Ticket #18488, comment 10
- Timestamp:
- 08/26/2012 07:54:30 PM (13 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #18488, comment 10
initial v1 2 2 3 3 {{{ 4 function SimpleXMLElement_to_ array( $xml ) {4 function SimpleXMLElement_to_stdClass( $xml ) { 5 5 $arr = array(); 6 6 foreach ($xml as $element) { … … 8 8 $e = get_object_vars($element); 9 9 if (!empty($e)) { 10 $arr[$tag] = $element instanceof SimpleXMLElement ? $this->SimpleXMLElement_to_ array($element) : $e;10 $arr[$tag] = $element instanceof SimpleXMLElement ? $this->SimpleXMLElement_to_stdClass($element) : $e; 11 11 } 12 12 else { … … 18 18 }}} 19 19 20 Could we add a similar function to WordPress ''(maybe `wp_SimpleXMLElement_to_ array()`)'' so that people can easily convert `SimpleXMLElement`s to usable formats and also have the `set_transient()` use this function to enable `SimpleXMLElement`s to be saved without requiring the developer to handle it explicitly? The `SimpleXMLElement` could be reconstituted in `get_transient()` for parity between set and get.20 Could we add a similar function to WordPress ''(maybe `wp_SimpleXMLElement_to_stdClass()`)'' so that people can easily convert `SimpleXMLElement`s to usable formats and also have the `set_transient()` use this function to enable `SimpleXMLElement`s to be saved without requiring the developer to handle it explicitly? The `SimpleXMLElement` could be reconstituted in `get_transient()` for parity between set and get. 21 21 22 Alternately still include the function but throw an error indicating the user is trying to save a `SimpleXMLElement` and tell them they need to use `wp_SimpleXMLElement_to_ array()` to transform it first?22 Alternately still include the function but throw an error indicating the user is trying to save a `SimpleXMLElement` and tell them they need to use `wp_SimpleXMLElement_to_stdClass()` to transform it first?