php数组 *** 作(字符串转数组,数组降维,判断数组是否重复)

php数组 *** 作(字符串转数组,数组降维,判断数组是否重复),第1张

概述//定义瓶码字符串$bianhaop_str=substr($bianhaop_str,1);$bianhaop_arr=explode(',',$bianhaop_str);if(!empty($bianhaop_arr)){//判断本身是否存在重复项if(count(array_unique($bianhaop_a
 // 定义瓶码字符串            $bianhaop_str = substr($bianhaop_str,1);            $bianhaop_arr = explode(',', $bianhaop_str);            if(!empty($bianhaop_arr)){                //判断本身是否存在重复项                if(count(array_unique($bianhaop_arr))!=count($bianhaop_arr)){                    Db::rollback();                    return ['status'=>0,'msg'=>'导入的瓶码重复'];                }                //验证瓶码                $bpListarr=Db::name('goodListsp')->where('bianhaop','neq','')->distinct(true)->fIEld('bianhaop')->select();                if(!empty($bpListarr)){                    $bpList=$this->array_to_arr($bpListarr, 'bianhaop');//二维数组转一维                    foreach ($bianhaop_arr as $bey => $bue) {                        if(in_array($bue, $bpList)){//在数组里是否存在某项                             Db::rollback();                            return ['status'=>0,'msg'=>'瓶码'.$bue.'重复'];                        }                    }                }            }

//二维数组转一维数组
public function array_to_arr($array, $ID)
{
$arr = array();
foreach ($array as $key => $val) {
array_push($arr, $val[$ID]);
}
return $arr;
}

 

 

总结

以上是内存溢出为你收集整理的php数组 *** 作(字符串转数组,数组降维,判断数组是否重复)全部内容,希望文章能够帮你解决php数组 *** 作(字符串转数组,数组降维,判断数组是否重复)所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/sjk/1167670.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-01
下一篇 2022-06-01

发表评论

登录后才能评论

评论列表(0条)

保存