continue 2 表示跳出两层
continue 默认跳出一层if (count($content_arr) > 0 ) { // 获取相应的goods数据 $goodsdata = array(); foreach ($content_arr as $k_goods => $v_goods) { foreach ($goodslist as $k_g_list => $v_g_list) { if ($v_g_list['goods_id'] == $v_goods) { $goodsdata[] = $v_g_list; continue 2; // 跳出两层,直接到达content_arr的foreach中,if也算一层 } } }}
这里的continue 2可以减少不必要的程序运算。提升加载速度。