Removing quotes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux