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 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); 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 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); 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 Link to comment https://forums.phpfreaks.com/topic/165679-search-result-problem/#findComment-873955 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.