The Technology database of Duke Yin

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;
		}

# #

评论关闭