php - Complex for each to retrieve array values -


i working on project creates array many dimensions. print_r() results in such:

array (  [campaigns] => array (      [0] => array (          [campaignid] => 1          [did] => 2394434444          [fwddid] => 3214822821          [productid] => 1          [campaignname] => fort myers bus #1          [productname] => calltrack - sharktek          [active] => 1 [companyid] => 1 )       [1] => array (          [campaignid] => 4          [did] => 2394434445          [fwddid] => 3214822821          [productid] => 1          [campaignname] => cape coral billboard #2          [productname] => calltrack - sharktek          [active] => 1 [companyid] => 1 )       [2] => array (          [campaignid] => 5          [did] => 2392146000          [fwddid] => 3214822821          [productid] => 1          [campaignname] => test campaign          [productname] => calltrack - sharktek          [active] => 1          [companyid] => 1 )     )  ) 

i trying create foreach loop select campaignids , use them in each loop, unfortunately, have not been able so.

because using codeigniter, unable simple echo results in controller, rather have pass values want array send view

thank time , efforts, appreciated!

if want campaignids foreach on later , have php >= 5.5.0 use array_column:

$ids = array_column($array, 'campaignid'); 

if php < 5.5.0 foreach on $array['campaigns'].

foreach($array['campaigns'] $campaign) {     $ids[] = $campaign['campaignid']; } 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -