Two-dimensional array SimpleXMLElementObject to a normal two-dimensional array

Source: Internet
Author: User
The two-dimensional array SimpleXMLElementObject is converted to a two-dimensional array with SimpleXMLElement Object output under the ordinary two-dimensional array. how can we remove all SimpleXMLElement objects from the two-dimensional array into a normal two-dimensional array.

Array ([0] => SimpleXMLElement Object ([FavType] => 2 [FreeSum] => 1500 [FreeCurrent] => 965 [FavCode1] => 1 [FavCode2] => 4 [FavOfferInfo] => 201407 enjoy a 4G 299 yuan package)
[1] => SimpleXMLElement Object ([FavType] => 2 [FreeSum] => 500 [FreeCurrent] => 18 [FavCode1] => 1 [FavCode2] => 2 [FavOfferInfo] => 201407 enjoy a 4G 299 yuan package)
[2] => SimpleXMLElement Object ([FavType] => 3 [FreeSum] => 30 [FreeCurrent] => 30 [FavCode1] => 4 [FavCode2] => 8 [FavOfferInfo] => Tianyi-group 0 RMB 30 m backward traffic package)
[3] => SimpleXMLElement Object ([FavType] => 3 [FreeSum] => 30 [FreeCurrent] => 30 [FavCode1] => 4 [FavCode2] => 8 [FavOfferInfo] => a 30 m provincial traffic package provided by Tianyi customer service)
[4] => SimpleXMLElement Object ([FavType] => 3 [FreeSum] => 4096 [FreeCurrent] => 1857.32 [FavCode1] => 4 [FavCode2] => 8 [FavOfferInfo] => 201407 enjoy a 4G 299 yuan package ))


Reply to discussion (solution)

function ObjectToArray($o) {  if(is_object($o)) $o = get_object_vars($o);  if(is_array($o))     foreach($o as $k=>$v) $o[$k] = ObjectToArray($v);  return $o;}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.