Jump to content

Problem with Nested Array


desmod

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
https://forums.phpfreaks.com/topic/284073-problem-with-nested-array/
Share on other sites

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.