Warning: get_class() expects parameter 1 to be object
arrays, php
Solution
simply add is_object check
if (is_object($simpleXmlElementObject) && get_class($simpleXmlElementObject) == SIMPLE_XML_ELEMENT_PHP_CLASS) {
Problem
I have a written a code a week back and it was working fine. But today when I chekced it gave me some problem like ``` Warning: get_class() expects parameter 1 to be object, array given in /home/ccc/public_html/horoscope/xml2json.php on line 182 Warning: get_class() expects parameter 1 to be object, string given in /home/ccc/public_html/horoscope/xml2json.php on line 182 Warning: get_class() expects parameter 1 to be object, string given in /home/ccc/public_html/horoscope/xml2json.php on line 182 Warning: get_class() expects parameter 1 to be object, string given in /home/ccc/public_html/horoscope/xml2json.php on line 182 Warning: get_class() expects parameter 1 to be object, string given in /home/ccc/public_html/horoscope/xml2json.php on line 182 ``` The part of my code is ``` $currentDate = date("n/j/Y"); echo($hdate); require_once("xml2json.php"); $testXmlFile = "http://www.findyourfate.com/rss/horoscope-astrology-feed.asp?mode=view&todate=$currentDate"; echo($testXmlFile); $xmlStringContents = file_get_contents($testXmlFile); $jsonContents = ""; $jsonContents = xml2json::transformXmlStringToJson($xmlStringContents); $obj =json_decode($jsonContents); $rows = array(); foreach($obj->rss->channel->item as $item) ``` the 182 line in xml2json is ``` if (get_class($simpleXmlElementObject) == SIMPLE_XML_ELEMENT_PHP_CLASS) { // Get a copy of the simpleXmlElementObject $copyOfsimpleXmlElementObject = $simpleXmlElementObject; // Get the object variables in the SimpleXmlElement object for us to iterate. $simpleXmlElementObject = get_object_vars($simpleXmlElementObject); } ``` here is the pastebin link for var_dump of simpleXMLElement Object http://pastebin.com/MPQfdQVx Can someone please help me out that what suddenly happened that its not working. Thanks