php trim()是否删除换行符? [英] Does php trim() remove line breaks?
问题描述
我正在创建一个应用程序,该应用程序需要从磁读取器中刷卡".从磁性阅读器返回的字符串在文本后有换行符.我可以使用php trim()删除换行符(以及显然的任何前置或后置空格)吗?
I am creating an application that takes a "swipe" from a magnetic reader. The string that is returned from the magnetic reader has a line break after the text. Can I use php trim() to remove the linebreak (and obviously any pre or post whitespace)?
推荐答案
是的,请参见手册:
此函数返回从
str
的开头和结尾去除空格的字符串.如果没有第二个参数,trim()
将删除这些字符:
This function returns a string with whitespace stripped from the beginning and end of
str
. Without the second parameter,trim()
will strip these characters:
" "
(ASCII 32(0x20)),普通空格.
"\t"
(ASCII 9(0x09)),一个制表符.
"\n"
(ASCII 10(0x0A)),换行(换行).
"\r"
(ASCII 13(0x0D)),回车符.
"\0"
(ASCII 0(0x00)),NUL字节.
"\x0B"
(ASCII 11(0x0B)),一个垂直制表符.
" "
(ASCII 32 (0x20)), an ordinary space.
"\t"
(ASCII 9 (0x09)), a tab.
"\n"
(ASCII 10 (0x0A)), a new line (line feed).
"\r"
(ASCII 13 (0x0D)), a carriage return.
"\0"
(ASCII 0 (0x00)), the NUL-byte.
"\x0B"
(ASCII 11 (0x0B)), a vertical tab.
这篇关于php trim()是否删除换行符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!