Home > Backend Development > PHP Tutorial > Solution to the problem of many spaces when php submits textarea data to mysql_PHP Tutorial

Solution to the problem of many spaces when php submits textarea data to mysql_PHP Tutorial

WBOY
Release: 2016-07-13 10:11:19
Original
1062 people have browsed it

Solution to the problem of many spaces when php submits textarea data to mysql

Some friends may find us after submitting the html to php for processing and saving the data to mysql. When reading data from mysql again, there will be a lot of spaces. So if we check it directly in mysql and there is no space, what is the problem and how to deal with it.

Solution to the problem that there are always a lot of spaces in textarea

Problem description:

When reading mysql data into textarea in php, there are always many spaces at the beginning and end. When viewing the data in the data table, there are no spaces.

Cause of the problem:

The content should be written against the textarea, and there should be no spaces or line breaks after the textarea.

Solution:

The code is as follows:

The code is as follows:

echo str_replace(' ', '', 'ab ab');
//Output "abab'
?>


Or use

The code is as follows:

echo strtr('ab ab', array(' '=>''));
// Output "abab"
?>

Supplement:

The newline character in php textarea is "rn"

Not 'n'

Not "
"

Not 'rn'

Not 'r'+'n'

I hope this article will be helpful to everyone’s PHP programming design.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/930080.htmlTechArticleThe solution to the problem of many spaces when php submits textarea data to mysql. Some friends may find that we submit it to in html After php processes and saves the data into mysql, we will find that we start again from...
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template