Duke Yin's Technology database

PHP Foreach 多个数组

单个数组

 foreach ( $imgurls as $imgurl ){
echo $imgurl;
}

两个数组

 foreach ( array_combine($imgurls, $attach_ids) as $imgurl => $attachid ){
echo $imgurl;
echo $attachid;
}

三个及以上数组

 foreach ( array_map(NULL, $imgurls, $attach_ids, $img_medium_urls) as $x ){
list($imgurl, $attach_id, $img_medium_url) = $x;
echo $imgurl;
echo $attach_id;
echo $img_medium_url;
}

# #

引用关闭,但你能发布评论.

评论