desmod Posted November 19, 2013 Share Posted November 19, 2013 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! Quote Link to comment Share on other sites More sharing options...
akphidelt2007 Posted November 19, 2013 Share Posted November 19, 2013 Try this $xaxis[]=$channel[0][0]; Quote Link to comment Share on other sites More sharing options...
Solution Barand Posted November 19, 2013 Solution Share Posted November 19, 2013 (edited) foreach ($xaxis as $k => &$v) { $a = (array)$v; $v = $a[0]; } echo '<pre>',print_r($xaxis, true),'</pre>'; result Array ( [0] => 1 [1] => 6 [2] => 11 ) Edited November 19, 2013 by Barand 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.