What would seem to be a simple operations is completely botched by the encoding here. I just want to check if the first character of a string is £. My php file itself is encoded UTF8-Without BOM. Thanks!
<?php
print "<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.1//EN' ";
print "'http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd'>\n";
print "<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='eng' lang='en'>\n";
print "<head>\n";
print "<meta http-equiv='Content-Type' content='text/html; charset=utf-8' />\n";
print "<title>WAMP</title>\n";
print "<meta name='Description' content='Website Under Construction' />\n";
print "</head>\n";
print "<body>\n";
print "<p>\n";
$temp = "£Hello";
$charArray = preg_split('//', $temp, -1);
// preg_match_all('/./', $temp, $charArray);
print_r ($charArray);
print "<br />First Char: $temp[0]";
print "</p>\n";
print "</body>\n";
print "</html>";
?>
Output:
Array ( [0] => [1] => � [2] => � [3] => H [4] => e [5] => l [6] => l [7] => o [8] => )
First Char: �
Desired Output:
Array ( [0] => [1] £ [2] => H [3] => e [4] => l [5] => l [6] => o [7] => )
First Char: £
Instead of
$temp[0]which is not multi-byte aware, trymb_substr():