Jump to content

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

)
Edited by desmod

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>';

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 by desmod
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.