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
Post a Comment