欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

获取字符串指定字符 前后 的字符串

程序员文章站 2022-07-14 19:27:10
...

public function err_redisOp()
{
$redis = new Redis();
$redis->connect(‘localhost’,6379);

    $res = $redis->hKeys('order_bc_api_err');
    $data = array_slice($res,0,5);//获取$res数组中的 前5条数据

    foreach ($data as $data_){

        $order_sn = substr($data_,0,strrpos($data_,'_+_'));//获取$data_字符串中出现 '_+_' 前的字符串
        $express_num = substr($data_,strrpos($data_,"_")+3);//获取$data_字符串中出现 '_' 后3位 的字符串
        $condition['order_sn'] = $order_sn;
        $condition['express_num'] = $express_num;
        $model_customs_order_bc = Model('customs_order_bc');
        $res = $model_customs_order_bc->getCustomsOrderInfo(array('order_sn'=>$order_sn,'express_num'=>$express_num));

        if(!empty($res)){
            $key = $order_sn.'_+_'.$express_num;
            var_dump($key);
            $res = $redis->hDel('order_bc_api_err',$key);
        }
    }
}