PHP: Get all array in foreach -


hi not experienced wiht php need help.

i trying list array giving me first array item , not all

here code

i getting database query

array ( [item] => hot, categories, activity ) 

below foreach loop

$sorted = $order; echo '<pre>'; print_r($sorted); echo '</pre>';  $temp_nav = array();  foreach ($sorted $key) {      if(isset($navigation[$key]))          $temp_nav[$key] = $navigation[$key];  }  $navigation = $temp_nav;  echo '<pre>'; print_r($navigation); echo '</pre>'; 

$order print_r result here

array (     [0] => hot     [1] => categories     [2] => activity ) 

now result getting print_r($sorted); below

array (     [0] => hot     [1] => categories     [2] => activity ) 

but when checked in foreach loop outputing fist item below

below rewsult $navigation

array (     [hot] = array         (             [url] => ./url             [lable] => hot items         ) ) 

but want value below

array(     'hot',     'categories',     'activity' ) 

so how can write code gives me result with item not first item

you filtering

if(isset($navigation[$key]))  

and shown obvious $navigation has key 'hot' list {'hot','categories','activity'}

if assumption wrong please provide output of print_r($navigation)


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -