Removing quotes

From: Date: Tue, 10 Oct 2006 07:04:02 +0000
Subject: Removing quotes
Groups: php.general 
Request: Send a blank email to php-general+get-242883@lists.php.net to get a copy of this message
Someone kindly gave me this once. I now need to reverse engineer it to remove the quotes and plus signs from $searchenquiry. Is it as simple as this? // FINAL RESULT: [+"john" +"johnston"] $sEnquiry = preg_replace("/\s+/", "+", $sEnquiry); // RESULT: ["john" "johnston"] $sEnquiry = preg_replace("/\s+/", "\"", $sEnquiry); // RESULT: [john johnston] --------original code----------------------------------------------- $sEnquiry = preg_replace("/\s+/", " ", $sEnquiry); // remove whitespace from beginning & end
   // RESULT: [john    johnston]
$sEnquiry = preg_replace("/\s+/", " ", $sEnquiry); // replace internal whitespace with single spaces // RESULT: [john johnston] $sEnquiry = str_replace(" ", "\" +\"", $sEnquiry); // replace each space with quote-space-plus-quote // RESULT: [john" +"johnston] $sEnquiry = "+\"" . $sEnquiry . "\""; // add beginning & ending delimiters // FINAL RESULT: [+"john" +"johnston"]

« previous php.general (#242883) next »