glenelkins Posted June 14, 2006 Share Posted June 14, 2006 how can i test a sting for a partial match? i tried the following but it does not work:[code]// Example$search_for = "Helen" // full text could be Helen Lee Scott$profileCount = 0;while ($profileArray = mysql_fetch_array($result)) { // Check the bride first if (strpos($profileArray['bride'],$search_for) > 0) { // Found part of the name $found_profileArray[$profileCount] = $profileArray['bride']; } $profileCount++;}if (!empty($profileArray)) { ACTIONS} else { ACTIONS}[/code] Quote Link to comment https://forums.phpfreaks.com/topic/11957-search-string-for-partial-match/ Share on other sites More sharing options...
wildteen88 Posted June 14, 2006 Share Posted June 14, 2006 You might want to look into [a href=\"http://uk.php.net/manual/en/function.preg-match.php\" target=\"_blank\"]preg_match[/a] it will be more accurate. Quote Link to comment https://forums.phpfreaks.com/topic/11957-search-string-for-partial-match/#findComment-45421 Share on other sites More sharing options...
phpvolution Posted June 14, 2006 Share Posted June 14, 2006 preg_match()but I'm horrid with regular expressions so hopefully someone can type that up quick. Quote Link to comment https://forums.phpfreaks.com/topic/11957-search-string-for-partial-match/#findComment-45422 Share on other sites More sharing options...
joquius Posted June 14, 2006 Share Posted June 14, 2006 how about strstr ( ) { found } else { not found } Quote Link to comment https://forums.phpfreaks.com/topic/11957-search-string-for-partial-match/#findComment-45439 Share on other sites More sharing options...
glenelkins Posted June 14, 2006 Author Share Posted June 14, 2006 thanks guys will look into that Quote Link to comment https://forums.phpfreaks.com/topic/11957-search-string-for-partial-match/#findComment-45447 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.