Q-net > Article Tutorials > Programming design > PHP Delete a string of spaces and newline characters ultimate Method string newline character file encoding Web page encoding hidden characters
the ultimate method of removing spaces and line breaks
This article mainly introduces the PHP to remove string newline character examples, the following sorting out the common way to remove the line, the need for friends can refer to the following The 1th way: Code is as follows:
PHP-compatible with all systems to remove newline regular and Php_eol variables
PHP to get rid of HTML or string with newline characters, this for Linux, WINDOWS, Mac system is supported
$v ["content"] = Str_replace (Php_eol, ", $v [" content "]);
A small package, in fact, different platforms have different implementations. Why are you doing this? It can be a world that is diverse.Originally UNIX and the world had to replace it with/N, but windows in order to reflect their differences. To use/
In the Unix world to line up with/n instead, but windows in order to reflect his differences, the use of/r/n, more interesting is the Mac with/R. So the UNIX series with the/n,windows series with the/r/n,mac with/R, so that you write the program on
One, the following example can remove extra whitespace
The code is as follows
$STR = "This line containstliberal RN with Whitespace.nn";The leading/trailing whitespaceRemove the start and end blank Www.111cn.net$str =
For example, the following code:
Copy Code code as follows:
Echo ' hello\n ';
echo ' World ';
?>
The newline character in the program is output directly, and the line cannot be wrapped correctly, and the solution is to change
I accidentally saw this function code on the Internet and haven't tried it yet. I will try it later. Add to favorites. Instructions for use:
// Load the function
Include_once ('phpcodezip. php ');
// Create an encrypted file (the Directory of the
Instructions for use:
// Load the FunctionInclude_once ('phpcodezip. php ');// Create an encrypted file (the directory of the PHP file to be encrypted by sourceDir and the directory of the files encrypted by targetDir)$ Encryption = new PhoCodeZip (
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.