Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Arno Welzel Newsgroups: comp.lang.php Subject: Re: str_replace does not like empty quotes Date: Fri, 20 Jun 2014 11:01:04 +0200 Lines: 49 Message-ID: <53A3F850.500@arnowelzel.de> References: <1kcemjreijezv$.k2q3x4bl6eoc.dlg@40tude.net> <53A38C39.3020405@arnowelzel.de> <7heper378zqa.dovihixf4du2.dlg@40tude.net> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: individual.net HHIG8DbwgM9Ujo4+31h4PgnBrdM4lxHDWQiZ4XpJrbZe0ufbwg Cancel-Lock: sha1:o2OBpjWFy5v8qrxzwYAFs4Zu8G0= User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 In-Reply-To: <7heper378zqa.dovihixf4du2.dlg@40tude.net> X-Enigmail-Version: 1.6 Xref: csiph.com comp.lang.php:13927 richard, 2014-06-20 04:13: > On Fri, 20 Jun 2014 03:19:53 +0200, Arno Welzel wrote: > >> richard, 2014-06-20 01:33: >> >>> $a=str_replace($a,"\",""); >>> >>> This generates the error: Unexpected "". >>> >>> http://www.php.net//manual/en/function.str-replace.php >>> >>> While here in the manual, they do precisely the same thing! >> >> No - they don't! >> >> Use: $a=str_replace($a,"\"",""); >> >> Beware of the double quotes, since \ starts an escape - this means, the >> meaning of the second quote (") is NOT "end string here". >> >> To make this more clear: >> >> >> " <- String starts here. \" <- This just ONE character end here -> " > > That could be the problem as some times the \ shows and some times it > doesn't. > I've tried several combinatiosn, still the \ remains. > > As for the technically correct proper order it is > search, replace, subject. No - it isn't - READ: str_replace ( $search , $replace , $subject [, int &$count ] ) This function returns a string or an array with all occurrences of search in subject replaced with the given replace value. -- Arno Welzel http://arnowelzel.de http://de-rec-fahrrad.de http://fahrradzukunft.de