Home >php教程 >php手册 >php解决input输入多个空格只显示一个的问题

php解决input输入多个空格只显示一个的问题

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-05-25 16:52:571140browse

这里简单的介绍了关于php解决input输入多个空格只显示一个的问题,我们利用了chr(32)来替换成html空格符,实例代码如下:

<body> 
<form id="form1" name="form1" method="post" action=""> 
  <label for="textfield"></label> 
  <input type="text" name="txt" id="txt" /> 
  <input type="submit" name="button" id="button" value="提交" /> 
</form> 
</body> 
</html> 
<?php
if( $_POST ) 
{ 
    $txt = $_POST[&#39;txt&#39;]; 
    echo $txt.&#39;<br />&#39;; 
    echo str_replace(chr(32),&#39; &#39;,$txt); 
} 
?>


永久地址:

转载随意~请带上教程地址吧^^

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn