This is because ¡is actually a multibyte character in UTF that PHP does not handle properly through array access ( [0] ). Instead, you'll want to explore multibyte functions: http://php.net/manual/en/book.mbstring.php
This should work as you expect:
$str = '¡hola!'; echo mb_substr($str, 0, 1, 'UTF-8'); // prints ¡ echo mb_substr($str, 1, 1, 'UTF-8'); // prints h echo mb_substr($str, 2, 1, 'UTF-8'); // prints o
source share