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! Link to comment https://forums.phpfreaks.com/topic/284073-problem-with-nested-array/ Share on other sites More sharing options...
akphidelt2007 Posted November 19, 2013 Share Posted November 19, 2013 Try this $xaxis[]=$channel[0][0]; Link to comment https://forums.phpfreaks.com/topic/284073-problem-with-nested-array/#findComment-1459071 Share on other sites More sharing options...
Barand Posted November 19, 2013 Share Posted November 19, 2013 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 ) Link to comment https://forums.phpfreaks.com/topic/284073-problem-with-nested-array/#findComment-1459073 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.