S
S
sadieff2017-02-09 14:19:07
PHP
sadieff, 2017-02-09 14:19:07

Stripos in the MIGX extension filter - how to make it work correctly with Cyrillic?

Good day! I'm picking the MIGX extension - its filter. I need to display records where a keyword occurs - case insensitive. The code snippet in the extension is responsible for this:

case 'contains':
      $output = strpos($subject, $operand) !== false ? $then : (isset($else) ? $else : '');
break;

I reduced everything even to lower case, I use stripos instead of strpos:
case 'contains':
  $subject = strtolower($subject);
  $operand = strtolower($operand);
        $output = stripos($subject, $operand) !== false ? $then : (isset($else) ? $else : '');
break;

But it doesn't want to work point-blank... With Latin characters, the case is not important, but in Russian words it does not find an occurrence... CHAYDNT?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
sadieff, 2017-02-09
@sadieff

Guys, it was all about php version. It was 5.3, changed to 5.6 and began to work. Or it was necessary to prescribe the data encoding.

I
Ivan, 2017-02-09
@LiguidCool

This seems to be normal behavior for unicode.
Try strpos first by making it smaller.
There is also mb_strpos.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question