PHP中如何检测字符串中存在空格?strstrstr_replace用什么?

解决方案 »

  1.   

    strpos
    preg_match
    国内超强ORM类
    http://code.google.com/p/queryphp/downloads/list
      

  2.   


    <?php
    $str = "fdsafdaf  fdafsaf";
    echo strpos($str," ");
    // the result is 8?>
      

  3.   

    strpos(string,find,start)The strpos() function returns the position of the first occurrence of a string inside another string.If the string is not found, this function returns FALSE.
    <?php
    if(strpos("Hello world!"," ")){
    echo '有空格';
    }else{
    echo '没有空格';
    }
    ?> 
      

  4.   

    $s = '字符串';
    strpos(chr(13, $s));
      

  5.   

    $s = '字符串';
    strpos(chr(13), $s);
      

  6.   

    if(strpos(' ',$str)!==false){
        //这里有空格.
    }