WordPress.org

Make WordPress Core

Changes between Initial Version and Version 1 of Ticket #18488, comment 10


Ignore:
Timestamp:
08/26/12 19:54:30 (3 years ago)
Author:
mikeschinkel
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #18488, comment 10

    initial v1  
    22 
    33{{{ 
    4 function SimpleXMLElement_to_array( $xml ) { 
     4function SimpleXMLElement_to_stdClass( $xml ) { 
    55  $arr = array(); 
    66  foreach ($xml as $element) { 
     
    88    $e = get_object_vars($element); 
    99    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; 
    1111    } 
    1212    else { 
     
    1818}}} 
    1919 
    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. 
     20Could 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. 
    2121 
    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? 
     22Alternately 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?