Jump to content

Array not working after moving to PHP 5.4


desmod

Recommended Posts

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
(
)

)

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.