Discussion:
mb_substr_count() for Arabic
Pablo Navarrete
2014-10-21 11:54:21 UTC
Permalink
Dear All,

Usually I don't directly contact people online, but I'm out of my zone, and
even in Stackoverflow I couldn't find an answer to my question.

I hope is not too much trouble and you can help me with this.

I'm writing a code to detect languages. I've set all the configuration on
MySQL and PHP to detect a language on a given text and so far everything
works fine for all languages except Arabic.

I'm using the function mb_substr_count to see how many times a word is used
in the text, but for Arabic it returns 0. Since I don't really know the
language I've tried many things. Reversing the text, trying different
settings on the encoding...etc

But nothing works, Funny thing is, when I use strpos() it detects the
patterns in the text.
So hopefully you had to deal with this things before, and could help me on
what I'm doing wrong.

** The strings are displayed correctly on the web and in MySQL, just that
function doesn't seem to work.

** You can see my post on Stackoverflow here
http://stackoverflow.com/questions/26313270/how-count-an-arabic-substring-with-substr-count-on-php

** I passed the function to some java developer friends. They translated
the code but seem to have the same issue.

Hope you can help me,

Thanks,

Pablo N.

Loading...