note 106653 added to function.str-replace

From: Date: Thu, 24 Nov 2011 20:15:30 +0000
Subject: note 106653 added to function.str-replace
Groups: php.notes 
Request: Send a blank email to php-notes+get-184665@lists.php.net to get a copy of this message
I hope this helps someone who has gone insane for 4 hours... If you have someone posting weird windows curly quotes into your forms and you cannot replace them using str_replace. I tried using mb_convert_encoding to convert the string to UTF-8 and then to do a str_replace but still no joy. I tried to str_replace using the \xe2\x80\x98 codes and also using the chr(145), chr(146), chr(147) codes. Nothing worked... It would replace the quotes but then ADD a question mark in a diamond !!!! no idea why.. in the end i just url encoded the string and replaced teh html codes: $search_weird_chars = array( '%E2%80%99', '%E2%80%99', '%E2%80%98', '%E2%80%9C', '%E2%80%9D' ); $this->post_array[$key] = urlencode($this->post_array[$key]); $this->post_array[$key] = str_replace($search_weird_chars, "'", $this->post_array[$key]); $this->post_array[$key] = urldecode($this->post_array[$key]); this works although it is a totally retarded thing to have to do .. oh well. :-) ---- Server IP: 69.147.83.197 Probable Submitter: 81.159.83.197 ---- Manual Page -- http://www.php.net/manual/en/function.str-replace.php Edit -- https://master.php.net/note/edit/106653 Del: integrated -- https://master.php.net/note/delete/106653/integrated Del: useless -- https://master.php.net/note/delete/106653/useless Del: bad code -- https://master.php.net/note/delete/106653/bad+code Del: spam -- https://master.php.net/note/delete/106653/spam Del: non-english -- https://master.php.net/note/delete/106653/non-english Del: in docs -- https://master.php.net/note/delete/106653/in+docs Del: other reasons-- https://master.php.net/note/delete/106653 Reject -- https://master.php.net/note/reject/106653 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#184665) next »