访问者的地理位置设置成china beijing chaoyang就能匹配到 设置能china zhejiang hangzhou就不行
<?php // 预先设置好的特殊地理位置 $activityName = array( array('china','beijing','chaoyang'), array('china','zhejiang','hangzhou'), // ...可以添加若干地理位置 ); // 预先设置好的特殊地理位置 //访问者的地理位置 $country="china"; $province="zhejiang"; $city="hangzhou"; $position = str_replace(' ', '', strtolower($country.'+'.$province.'+'.$city)); //访问者的地理位置 function checkActivity($actName,$position) { $pregmsg = explode('+',$position); foreach($actName as &$value) { for($i=0;$i<3;$i++) { if($value[$i]==$pregmsg[$i]) { if($i==0) { $value['ispregco'] = true; } if($i==1) { $value['ispregpr'] = true; } if($i==2) { $value['ispregci'] = true; } } } } foreach ($actName as $value) { if($value['ispregco'] && $value['ispregpr'] && $value['ispregci']) { echo'匹配到你在特殊的地理位置里'; } else{echo '你是普通访问者'; } } } checkActivity($activityName,$position);
What's wrong?
Please help me, God, how do I change this PHP code, but it never matches-PHP Chinese website Q&A-Please God, help me, how do I change this PHP code, but it never matches-PHP Chinese website Q&A
Let’s watch and learn.