Home > Backend Development > PHP Tutorial > Solution to the problem of many spaces when php submits textarea data to mysql, textareamysql_PHP tutorial

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

WBOY
Release: 2016-07-13 10:11:17
Original
1078 people have browsed it

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

The example in this article describes the solution to the problem of many spaces when php submits textarea data to mysql. Share it with everyone for your reference. The specific analysis is as follows:

Some friends may find that after we submit the html to php for processing and save the data to mysql, we will find that there will be a lot of spaces when we read the data from mysql again. Then if we view it directly in mysql, there will be no space. , what is this 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:

Copy code The code is as follows:
echo str_replace(' ', '', 'ab ab');
//Output "abab'
?>

Or use
Copy code 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/930186.htmlTechArticleSolution to the problem of many spaces when php submits textarea data to mysql, textareamysql This article describes how php submits textarea data The solution to the problem of many spaces in mysql. Share to...
Related labels:
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