problem encountered with stristr-based function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

I'm having a problem with the following function:

function terms($term,$field){
  if(strlen($term)>0){
    if(!stristr($term, $field) === FALSE) {
      $output = str_replace($term, "<b>".$term."</b>", $field);
    } elseif(!stristr(strtolower($term), $field) === FALSE) {
      $output = str_replace(strtolower($term),
"<b>".strtolower($term)."</b>", $field);
    } elseif(!stristr(strtoupper($term), $field) === FALSE) {
      $output = str_replace(strtoupper($term),
"<b>".strtoupper($term)."</b>", $field);
    } elseif(!stristr(ucfirst($term), $field) === FALSE) {
      $output = str_replace(ucfirst($term), "<b>".ucfirst($term)."</b>",
$field);
    }
  } else {
    $output = $field;
  }
  return $output;
}
I'm not comfortable enough with regex etc, so tried it my way, but no joy.

For info, I am trying to highlight search terms in results.

Any suggestions?

George

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux