Escaping characters by doubling them in PHP
问题 Is there a simple way to escape/unescape an arbitrary character in PHP by doubling it, for example: in ANSI SQL, "you can ""escape"" this way" in printf(), you can express a %% this way Escaping is quite easy with str_replace() , but reversing the process to unescape the string is not that easy, so does anyone know of a pair of functions, or a library to do this? The idea is that I need to serialize an array this way: array('a','b', '~','c') => 'a~b~~~~c' The individual strings cannot be