Unable to extract characters from string

I am trying to use some specific characters in a string. I need to go through each character of a string and identify the characters. However, some characters are converted to THREE CHARACTERS. Need help on how to save the character.

echo $instring = ("& ∨ = ⊢");
echo "\nLength of string: ".strlen($instring); 
for ($i = 0; $i < strlen($instring) ; $i++){
    $temp_str = substr($instring, $i,1);
    echo "\nChar: $i: $temp_str";
    $instring_arr[$i] = $temp_str;
}

HERE WORKING CODE. Thanks h2oooooo:

echo $instring = ("& ∨ = ⊢");
echo "\nLength of string: ".mb_strlen($instring, "UTF-8"); 
for ($i = 0; $i < mb_strlen($instring, "UTF-8") ; $i++){
    $temp_str = mb_substr($instring, $i,1,"UTF-8");
    echo "\nChar: $i: $temp_str";
    $instring_arr[$i] = $temp_str;
}
+4
source share
1 answer

I think you can just split the row, put all the parts in a table (or a list, or sometime else) and check the whole table until you find your specific characters.

I hope I help you.

0
source

Source: https://habr.com/ru/post/1542036/


All Articles