项目说明

  1. experts 专家表中字段以"1353416,1353417,1353418,1353419"以固定格式组成的字符串:手机号+“,”分隔符。
  2. 需要在专家未评审前,读取对应的数据记录;
  3. 专家评审后,生成对应的评审记录,取消项目信息字段内的管理信息;

筛选读取sql语句

LOCATE(substr,str)
返回字符串substr中第一次出现子字符串的位置 str。

  • 当检索出匹配结果,返回值>0,代表数据表中存在对应的数据记录。
 $filter_condition = " WHERE locate(" . $_COOKIE['user_phone'] . ", pro_experts4) > 0";

str_ireplace 函数替换

  • 当专家审批完成后,取消原数据表experts的关联信息。如某专家的手机号为135****3416,审批成功后,experts手机号被替换为空。

解决方案

存在的可能性:

  • 135----3415,135----3416 号码在后面,替换时需替换,135****3416
  • 135----3416,135----3415号码在后面,替换时需替换 135****3416,
  • 135----3415,135----3416,135----3417,号码在中间时,需替换135----3416,以及“,,”为“,”

str_ireplace(find,replace,string,count)
str_ireplace() 函数替换字符串中的一些字符(不区分大小写)。

    $pre_experts1 = str_ireplace($_COOKIE['user_phone'], '', $role_experts);
    $pre_experts = str_ireplace(',,', '', $pre_experts1);
        //去头掐尾;
        if (substr($pre_experts, -1) == ",") {
            $pre_experts = substr($pre_experts, 0, strlen($pre_experts) - 1);
        }
        if (substr($pre_experts, 0, 1) == ",") {
            $pre_experts = str_ireplace(',', '', substr($pre_experts, 0));
        }

@lockdata.cn