Z
Z
zhdoon2018-04-12 09:24:13
PHP
zhdoon, 2018-04-12 09:24:13

Why is the array printed correctly, and the array element with a crooked encoding?

Simple question.
Code:
print_r($arr[$i]);
Result prntscr.com/j44yxx
Code: Result prntscr.com/j44zoc M?
print_r($arr[$i][2]);

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
Lone Ice, 2018-04-12
@zhdoon

In the first option, you are accessing the $i-th element of the array, and in the second, you are accessing the 3rd character in this element. If you want to get exactly the element in the string, then use this:

$str="строка";
$chrArray=preg_split("//u", $str, -1, PREG_SPLIT_NO_EMPTY);
echo $chrArray[2];

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question