/* * 处理封面标题 文字竖排 * */ function get_pdf_title_cl($str){ if($str){ preg_match_all("/[0-9]{1}/",$str,$arrNum);/*检测数字数量*/ preg_match_all("/[a-zA-Z]{1}/",$str,$arrAl);/*检测字母数量*/ $newStr = preg_replace('/[^x{4e00}-x{9fa5}]/u', '', $str);/*检测文字数量*/ $zifu = mb_strlen($newStr,"utf-8"); $shuzi_num = count($arrNum[0]); $zimu_num = count($arrAl[0]); $zifu_num = $zifu; $num = $shuzi_num+$zimu_num+$zifu_num; $arr = ''; for ($i=0;$i<$num;$i++){ $wenzi = mb_substr($str,$i,1,'utf-8'); $arr = $arr.'<p>'.$wenzi.'</p>'; } $data['title'] = $arr.'<p>销</p><p>售</p><p>合</p><p>同</p>'; $data['status'] = 1; /*if($num <= 8){ }else{ $data['title'] = $str.'销售合同'; $data['status'] = 2; }*/ dump($data);die(); return $data; }else{ return ''; } }
效果:
array(2) { ["title"] => string(142) "<p>转</p><p>轮</p><p>+</p><p>三</p><p>床</p><p>R</p><p>T</p><p>O</p><p>废</p><p>气</p><p>处</p><p>销</p><p>售</p><p>合</p><p>同</p>" ["status"] => int(1) }