php去除数据库的数据空格

//遍历更新
foreach ($list as $key => $value) {
    $value[‘goodsname‘] = $this->trimall($value[‘goodsname‘]);
    $value[‘measureunit‘] = $this->trimall($value[‘measureunit‘]);
    $goodsLogic->saveByData($value,array(‘id‘=>$value[‘id‘]));
}
/**
 * 说明:新增/修改
 * 作者: panzhide
 * 时间: 2020/8/14
 * @param string $where
 * @return string
 */
public static function saveByData($data, $where = [])
{
    $model = BaseModelFactory::create(‘Goods‘, ‘stock‘);
    $res = $model->allowField(true)->save($data, $where);
    return $res;
}
//删除空格
public function trimall($str)
{
    $oldchar=array(" "," ","\t","\n","\r");
    $newchar=array("","","","","");
    return str_replace($oldchar,$newchar,$str);
}

 

php去除数据库的数据空格

上一篇:bzoj 1834 [ZJOI2010] network 网络扩容 题解


下一篇:JSP中用include标签动态引入其它文件报错:attribute for %>" is not properly terminated