desmod Posted November 22, 2013 Share Posted November 22, 2013 (edited) The array below worked fine in PHP 5.3 but it is returning empty results in PHP 5.4 What is causing it? This is the code I am using: $xaxis=array(); for ($i = 1; $i <= 3; $i++) { $chachg_time = $xml->xpath("//ns:BulkData[ns:Name='ChannelChangeHistory.{$i}.ChannelChangeTime']/ns:Value"); $chachg_time = $chachg_time[0]; $xaxis[] = $chachg_time[0]; } In PHP 5.3, I get the expected result: Array ( [0] => SimpleXMLElement Object ( [0] => 6 ) ) Array ( [0] => SimpleXMLElement Object ( [0] => 6 ) [1] => SimpleXMLElement Object ( [0] => 5 ) ) Array ( [0] => SimpleXMLElement Object ( [0] => 6 ) [1] => SimpleXMLElement Object ( [0] => 5 ) [2] => SimpleXMLElement Object ( [0] => 3 ) ) However, after moving to server running PHP 5.4, I get the following empty results: Array ( [0] => SimpleXMLElement Object ( ) ) Array ( [0] => SimpleXMLElement Object ( ) [1] => SimpleXMLElement Object ( ) ) Array ( [0] => SimpleXMLElement Object ( ) [1] => SimpleXMLElement Object ( ) [2] => SimpleXMLElement Object ( ) ) Edited November 22, 2013 by desmod Quote Link to comment Share on other sites More sharing options...
cyberRobot Posted November 22, 2013 Share Posted November 22, 2013 Have you tried echoing the other variables to see if they contain expected values? As $chachg_time changes, for example, you could add the following to see what it contains: echo '<pre>' . print_r($chachg_time, true) . '</pre>'; Quote Link to comment Share on other sites More sharing options...
desmod Posted November 22, 2013 Author Share Posted November 22, 2013 (edited) Interesting. When I do: $xaxis=array(); for ($i = 1; $i <= 3; $i++) { $chachg_time = $xml->xpath("//ns:BulkData[ns:Name='ChannelChangeHistory.{$i}.ChannelChangeTime']/ns:Value"); echo '<pre>' . print_r($chachg_time, true) . '</pre>'; $chachg_time = $chachg_time[0]; $xaxis[] = $chachg_time[0]; } In PHP 5.3 I get: Array ( [0] => SimpleXMLElement Object ( [0] => 2013-11-12T01:01:45.207Z ) ) Array ( [0] => SimpleXMLElement Object ( [0] => 2013-11-12T02:02:45.207Z ) ) Array ( [0] => SimpleXMLElement Object ( [0] => 2013-11-12T03:03:45.207Z ) ) In PHP 5.4 I get: Array ( [0] => SimpleXMLElement Object ( ) ) Array ( [0] => SimpleXMLElement Object ( ) ) Array ( [0] => SimpleXMLElement Object ( ) ) Also, when I do the code below in both, PHP 5.3 or PHP 5.4 $xaxis=array(); for ($i = 1; $i <= 3; $i++) { $chachg_time = $xml->xpath("//ns:BulkData[ns:Name='ChannelChangeHistory.{$i}.ChannelChangeTime']/ns:Value"); $chachg_time = $chachg_time[0]; echo '<pre>' .$chachg_time .'</pre>'; $xaxis[] = $chachg_time[0]; } I get the same result: 2013-11-12T02:10:00.153Z 2013-11-12T02:15:00.153Z 2013-11-12T02:20:00.153Z Edited November 22, 2013 by desmod Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.