Jump to content

Problem with Nested Array


desmod
Go to solution Solved by Barand,

Recommended Posts

When using the following code: 

$yaxis=array();
$xaxis=array();
for ($i = 1; $i <= $number_of_entries; $i++) {
$channel = $xml->xpath("//ns:BulkData[ns:Name='InternetGatewayDevice.LANDevice.1.WLANConfiguration.X_181BEB_ChannelDiagnostics.Result.{$i}.Channel']/ns:Value"); 
$channel = $channel[0];
$xaxis[]=$channel[0]; 


$apcount = $xml->xpath("//ns:BulkData[ns:Name='InternetGatewayDevice.LANDevice.1.WLANConfiguration.X_181BEB_ChannelDiagnostics.Result.{$i}.APcount']/ns:Value");
$apcount = $apcount[0]; 
$yaxis[]=$apcount[0];


}

I get the following results for $xaxis and $yaxis arrays:

 

print_r($xaxis);
Array ( 
[0] => SimpleXMLElement Object ( [0] => 1 ) 
[1] => SimpleXMLElement Object ( [0] => 6 ) 
[2] => SimpleXMLElement Object ( [0] => 11 ) 
)


print_r($yaxis);
Array (
[0] => SimpleXMLElement Object ( [0] => 3 ) 
[1] => SimpleXMLElement Object ( [0] => 8 ) 
[2] => SimpleXMLElement Object ( [0] => 6 ) 
) 

What I am looking for is only the value of the nested array.  Like this: 

print_r($xaxis); 
Array ( 
[0] => 1 
[1] => 6 
[2] => 11 
)

print_r($yaxis); 
Array ( 
[0] => 3 
[1] => 8 
[2] => 6 
) 

How can I achieve this?  Thanks for any help / suggestions!  

 

Link to comment
Share on other sites

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.