php - foreach as from multiple arrays in single query -


i have:

foreach($opts['img'] $img) { } 

i want add:

foreach($opts['lnk'] $lnk) 

which read, put them follows:

foreach($opts['img'] $img) {     foreach($opts['lnk'] $lnk)     {     } } 

however duplicates of results end 9 images instead of 3.

is there way of getting info both array's in same query? want end $img showing image address , $lnk showing link address.

for identical keys, use key in foreach:

foreach($opts['img'] $key => $img) {     $lnk = $opts['lnk'][$key];      echo "$img , $lnk"; } 

Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -