Can't get str_replace() to strip out spaces in a PHP string

前端 未结 7 1084
谎友^
谎友^ 2020-12-14 23:54

Hi, I am getting a PHP string which I need to strip the spaces out of. I have used the following code but when I echo $classname it just displays the string sti

7条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-14 23:59

    The problem might be the character not being a space, but another whitespace character.

    Try

    $classname = preg_replace('/\s/', '', $fieldname);
    

提交回复
热议问题