|
|
PHP explode分割字符串,字符串拆分
mysql数据表字段:jiguan=1,1,1,1,1
$cha['jg'] = "";
$bjid = Cookie::get('bjid');
$cha = $rows = RenyuanModel::alias('a')
->join('kehu b', 'a.kid = b.id')
->join('bumen c', 'a.bid = c.bmid')
->where(['a.rycd' =>1,'ryid' => $bjid])
->field('a.*,b.id,b.knames,c.bmid,c.bmname')
->find();
/*籍贯部分开始*/
//查询出籍贯,分割字符串
$jiguans = $cha['jiguan'];
$sheng = explode(',',$jiguans)[0];
$shi = explode(',',$jiguans)[1];
$xian = explode(',',$jiguans)[2];
$zhen = explode(',',$jiguans)[3];
$cun = explode(',',$jiguans)[4];
$chasheng = Db::table('dzsheng')->where('id',$sheng)->find();
$chashi = Db::table('dzshi')->where('id',$shi)->find();
$chaxian = Db::table('dzxian')->where('id',$xian)->find();
$chazhen = Db::table('dzzhen')->where('id',$zhen)->find();
$chacun = Db::table('dzcun')->where('id',$cun)->find();
$gang = '-';
$cha['jg'] = $chasheng['shname'].$gang.$chashi['sname'].$gang.$chaxian['xname'].$gang.$chazhen['zname'].$gang.$chacun['cname'].$gang.$cha['jiguanz'];
/*籍贯部分结束*/
$data = [
'code' => 200,
'rows' => $cha
];
return json($data);
|
|