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"]

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to