If PHP calls C # Webservice and determines whether data exists? If PHP calls C # Webservice and determines whether data exists?
Reply to discussion (solution)
$ Obj_xml = simplexml_load_string ($ result );
Print_r ($ obj_xml );
Your code is okay.
Talk about any questions
$ Obj_xml = simplexml_load_string ($ result );
Print_r ($ obj_xml );
Your code is okay.
Talk about any questions
I mean, if the flight stops on that day, there will be no flight data,
If no data exists, foreach ($ obj_xml-> NewDataSet-> Table1 as $ item) returns an error.
Warning: Invalid argument supplied for foreach () in D: \ xampp \ htdocs \ WS \ index. php on line 137
If (isset ($ obj_xml-> NewDataSet-> Table1) foreach ($ obj_xml-> NewDataSet-> Table1 ....
Or
If (is_array ($ obj_xml-> NewDataSet-> Table1) foreach ($ obj_xml-> NewDataSet-> Table1 ....
If (isset ($ obj_xml-> NewDataSet-> Table1) foreach ($ obj_xml-> NewDataSet-> Table1 ....
Or
If (is_array ($ obj_xml-> NewDataSet-> Table1) foreach ($ obj_xml-> NewDataSet-> Table1 ....
If (isset ($ obj_xml-> NewDataSet-> Table1) can
If (is_array ($ obj_xml-> NewDataSet-> Table1) does not work, and the original data is not displayed, I used to use if (is_array ($ obj_xml-> NewDataSet-> Table1) to find that I couldn't do it before posting it. can you explain why is_array cannot be used? $ Obj_xml-> NewDataSet-> is Table1 indeed an array? Not very clear?
Well, it's an object, not an array.
Echo gettype ($ obj_xml-> NewDataSet-> Table1); // object
However, count can return the correct number of members.
Echo count ($ obj_xml-> NewDataSet-> Table1); // 87
Well, it's an object, not an array.
Echo gettype ($ obj_xml-> NewDataSet-> Table1); // object
However, count can return the correct number of members.
Echo count ($ obj_xml-> NewDataSet-> Table1); // 87
Moderator: I deleted the post on the second floor. thank you!