初学php不久,一道题目,个人的做法是吧这些标题分别存到不同的数组,然后针对不同的数组进行循环遍历分别+=. 不过别人说这样还不如原来的,所以想请教下正确的方法是什么
$xcount=0; $pos = strpos($newtitle, ''); if($pos) $xcount+=3; $pos = strpos($newtitle, '卖肾'); if($pos) $xcount+=3; $pos = strpos($newtitle, '收肾'); if($pos) $xcount+=3; $pos = strpos($newtitle, '24小时'); if($pos) $xcount+=3;//24小时 $pos = strpos($newtitle, '咨询热线'); if($pos) $xcount+=3;//24小时 $pos = strpos($newtitle, '找小姐'); if($pos) $xcount+=6;//24小时 $pos = strpos($newtitle, '服务信息'); if($pos) $xcount+=6;//24小时 $pos = strpos($newtitle, '学生妹'); if($pos) $xcount+=6;//24小时 $pos = strpos($newtitle, '找小姐'); if($pos) $xcount+=6;//24小时 //
$pos = strpos($newtitle, '男女公关'); if($pos) { echo 'Fail, No Uid.';exit;} $pos = strpos($newtitle, '女公关'); if($pos) { echo 'Fail, No Uid.';exit;} $pos = strpos($newtitle, '男公关'); if($pos) { echo 'Fail, No Uid.';exit;} $pos = strpos($newtitle, '公关'); if($pos) { echo 'Fail, No Uid.';exit;} $pos = strpos($newtitle, '招聘'); 