且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

从php中的字符串中删除转义序列

更新时间:2023-02-23 09:33:36

strip c slashes()功能确实如此:

  stripcslashes( 'foo\r\\\
');


I'm working with a mysqldump file that has escaped character sequences. I need to know the length of a string as its database value, but the dump has escape characters in it, which add length to the string.

I've used stripslashes() which properly un-escapes single- and double-quotes, but it doesn't touch the \r\n.

I'm concerned there are other escaped character sequences in there that I'm not aware of. Is there a function I can use that will give me the true length of the string as it would be in the database? If I have to build my own function, what other sequences should it handle?

The strip c slashes() function does exactly that:

stripcslashes('foo\r\n');