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] 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. 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. 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 } 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 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
Archived
This topic is now archived and is closed to further replies.