vinpkl Posted July 12, 2009 Share Posted July 12, 2009 hi all i m showing search result according to query. $pnm=$row['product_name']; $pnm = explode(' ', $pnm); $qryc="select * from product_table where product_name LIKE '%$pnm[0]%' AND product_name LIKE '%$pnm[1]%' and category_id=4"; Now if somebody enters "Sony Ericsson T707" then it fetches "Sony Ericsson" as two separate words. I want that it should fetch "sony Ericsson" as one word like "SonyEricsson" removing their inbetween space. how can i do it. vineet Quote Link to comment https://forums.phpfreaks.com/topic/165679-search-result-problem/ Share on other sites More sharing options...
ignace Posted July 12, 2009 Share Posted July 12, 2009 $pnm = implode('', $pnm); Quote Link to comment https://forums.phpfreaks.com/topic/165679-search-result-problem/#findComment-873943 Share on other sites More sharing options...
vinpkl Posted July 12, 2009 Author Share Posted July 12, 2009 $pnm = implode('', $pnm); hi ignace Like the search term is "Sony Ericsson T707". By using your implode code the search term become "SonyEricssonT707". I want the term to become "SonyEricsson T707". I want to implode only first two words, not all. vineet Quote Link to comment https://forums.phpfreaks.com/topic/165679-search-result-problem/#findComment-873948 Share on other sites More sharing options...
ignace Posted July 12, 2009 Share Posted July 12, 2009 $firstword = array_shift($pnm); $secondword = array_shift($pnm); $pnm = implode('', array($firstword, $secondword)) . ' ' . implode(' ', $pnm); Quote Link to comment https://forums.phpfreaks.com/topic/165679-search-result-problem/#findComment-873951 Share on other sites More sharing options...
vinpkl Posted July 12, 2009 Author Share Posted July 12, 2009 $firstword = array_shift($pnm); $secondword = array_shift($pnm); $pnm = implode('', array($firstword, $secondword)) . ' ' . implode(' ', $pnm); hi ignace i didnt know anything about array_shift(). thanks. now its fine. vineet Quote Link to comment https://forums.phpfreaks.com/topic/165679-search-result-problem/#findComment-873955 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.