有一些朋友可能会发现我们在html提交给php处理保存数据到mysql中之后会发现我们再次从mysql读出数据时会有很多的空格了,那么我们如果直接在mysql中查看又没有空间,这是什么问题要如何处理呢.
textarea中总是有很多空格问题解决
问题描述:在php读取mysql数据到textarea中开头可结尾总有很多空格,在数据表中查看数据是没有空格的.
问题原因:内容应该顶着textarea写,textarea后不要有空格和换行.
解决办法,代码如下:
<?php echo str_replace(' ', '', 'ab ab'); //输出 "abab' //或者使用 <?php echo strtr('ab ab', array(' '=>'')); // 输出 "abab"
补充:php textarea中的换行符为"\r\n"
不是'\n'
不是"
"
不是'\r\n'
不是'\r'+'\n'

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Dreamweaver Mac version
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

WebStorm Mac version
Useful JavaScript development tools