dousong5492 2012-01-30 13:48 采纳率: 100%
浏览 23

Preg_match在文本框值中查找%

i have a textbox value i have to find out the % symbol in the textvalue can anyone suggest me how to do that ?

i have a textbox that contains some value and i have to find out whether that textbox contain % symbol or not

$camp_ttllimpression=$_POST['camp_ttllimpression'];
$camp_ttllclicks=$_POST['camp_ttllclicks'];
$camp_ttlleads=$_POST['camp_ttlleads'];
$camp_ttllsales=$_POST['camp_ttllsales'];
$hid=$_POST['hid'];
$camp_cpa_amnt=$_POST['camp_cpa_amnt'];
$camp_cpm_amnt=$_POST['camp_cpm_amnt'];
$camp_cpc_amnt=$_POST['camp_cpc_amnt'];
$camp_cpl_amnt=$_POST['camp_cpl_amnt'];
$camp_cpm_budgt=($camp_ttllimpression * $camp_cpm_amnt)/1000;
$camp_cpc_budgt=$camp_ttllclicks * $camp_cpc_amnt;
$camp_cpl_budgt=$camp_ttlleads * $camp_cpl_amnt;
$camp_cpa_budgt=$camp_ttllsales * $camp_cpa_amnt;
if($hid=="%") { echo Open;} else { echo $camp_cpa_budgt;}
  • 写回答

2条回答 默认 最新

  • doushaizhen1244 2012-01-30 13:53
    关注

    Substitute the correct key for $_POST['textfield'] since it isn't clear from your question. preg_match() is not needed-- this is better done with simple string operations.

    // To find out if it contains a % anywhere...
    if (strpos($_POST['texfield'], '%') !== FALSE) {
       // Contais a %
    }
    
    // To find out if it contains only a %
    if ($_POST['texfield'] === '%') {
       // Contains only %
    }
    
    评论

报告相同问题?

悬赏问题

  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 关于大棚监测的pcb板设计
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)