0

I have a textbox search form and the word " Περισσότερα ".

The word "ρισσότ" contains a Greek character with intonation: " ό ".

After I click on the submit button the program searches for " ρισσότ " and returns results like this:

Περισσότερα σχετικά με την τοποθεσία

When i type the word "ρισσοτ" without intonation, my program finds my word and shows it in the results but doesn't make it bold.

Περισσότερα σχετικά με την τοποθεσία

How can I make my program highlight the match in bold?

My PHP is this

$search_array = explode(' ', $search);
foreach ($search_array as $k => $v)
{
    $w = trim($v);
        if ($w)
    {
       $result[$i]['description'] = preg_replace('/(' . preg_quote($w, '/') . ')/siU', '<b>\\1</b>', $result[$i]['description']);
    }
}
John Stamoutsos
  • 353
  • 1
  • 3
  • 17
  • 1
    You probably want to replace all the accented characters with the non accented equivalent. There are many resources in the net about this. Also, this may work: http://php.net/manual/en/class.collator.php – fedorqui Oct 27 '14 at 15:05
  • I need a new example from above example – John Stamoutsos Oct 27 '14 at 15:09
  • With this answer the program replace the ό with o i don't wont to replace it but i show it as is but bold. – John Stamoutsos Oct 27 '14 at 15:31
  • The first few results for "php regex ignore accents" on Google all point to similar questions on this site. As @fedorqui says above, you will need to replace the accented characters with non-accented ones, or you could try this solution: http://stackoverflow.com/a/10837628/1255289 – miken32 Oct 27 '14 at 17:26
  • No this is a bad way, and is not working for me, and if it is, is a bad way! – John Stamoutsos Oct 27 '14 at 17:48

1 Answers1

-2
$search_array = explode(' ', $search);
foreach ($search_array as $k => $v)
{
    $w=trim($v);
    if($w)
      $result[$i]['description'] = '<b>'.$w.'</b>';

}
brandelizer
  • 342
  • 3
  • 17
  • This is the same code of my code, without preg_replace('/(' . preg_quote and i needed that. And with your code replace ό with o and show my only specify word – John Stamoutsos Oct 27 '14 at 16:55