Jump to content


Photo

search string for partial match


  • Please log in to reply
4 replies to this topic

#1 glenelkins

glenelkins
  • Members
  • PipPipPip
  • Advanced Member
  • 760 posts
  • LocationBridlington - East Riding of Yorkshire - United Kingdom

Posted 14 June 2006 - 08:04 AM

how can i test a sting for a partial match? i tried the following but it does not work:

// 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
}

http://thewebsolutionprovider.com - A Solution For Everything Web!

#2 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 14 June 2006 - 08:58 AM

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.

#3 phpvolution

phpvolution
  • Members
  • PipPip
  • Member
  • 13 posts

Posted 14 June 2006 - 09:00 AM

preg_match()
but I'm horrid with regular expressions so hopefully someone can type that up quick.

#4 joquius

joquius
  • Members
  • PipPipPip
  • Advanced Member
  • 319 posts

Posted 14 June 2006 - 09:57 AM

how about strstr ( ) { found } else { not found }
z..z..z..z..z..z..z..z..

#5 glenelkins

glenelkins
  • Members
  • PipPipPip
  • Advanced Member
  • 760 posts
  • LocationBridlington - East Riding of Yorkshire - United Kingdom

Posted 14 June 2006 - 10:42 AM

thanks guys will look into that
http://thewebsolutionprovider.com - A Solution For Everything Web!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users