<?php
/**
* User: Jack
* Date: 2017/11/6
* Time: 18:21
*/
header('Content-Type:text/html;Charset=utf-8');
//提供的商品编码
$product_str = "BT010500140005,BT010400640019,S59F1937DD40E5
,G593A8AA00D80F,BW010800390010";
$product_arr = explode(",", $product_str);
//查出来的商品编码
$ids = array(0 => 'BT010500140005', 1 => 'BT010400640019', 2 => 'S59F1937DD40E5',
3 => 'BW010800390010', 4 => 'G593A8AA00D80F');
$flag = true;
foreach ($product_arr as $val) {
if (!in_array($val, $ids)) {
$flag = false;
break;
}
}
if ($flag) {
echo "包含";
} else {
echo "不包含";
}
php利用in_array函数搜索数组中是否存在指定的值。
猜你喜欢
转载自blog.csdn.net/u013101178/article/details/81357378
今日推荐
周排行