Skip to content

Instantly share code, notes, and snippets.

@ve3
Last active August 13, 2020 14:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ve3/90d9871dc87d5408f6edd7b36cff75e1 to your computer and use it in GitHub Desktop.
Save ve3/90d9871dc87d5408f6edd7b36cff75e1 to your computer and use it in GitHub Desktop.
PHP: list Thai characters in array. แสดงอักขระภาษาไทยเป็น array.
<?php
echo '<meta charset="utf-8">' . PHP_EOL;
/*for ($i = 0; $i <= 255; $i++) {
$string = chr($i);
echo $i . ' =&gt; ';
echo iconv('tis-620', 'utf-8//IGNORE', $string);
//echo ' &nbsp; ';
echo '<br>' . PHP_EOL;
}*/
// thai characters (for chr() function) are 161-218, 223-251
echo '[';
// https://everythingfonts.com/unicode/thai
for ($i = 3585; $i <= 3642; $i++) {
echo '\'';
echo '&#' . $i . ';';
echo '\'';
echo ', ' . PHP_EOL;
}
for ($i = 3647; $i <= 3675; $i++) {
echo '\'';
echo '&#' . $i . ';';
echo '\'';
if ($i < 3675) {
echo ', ' . PHP_EOL;
}
}
echo ']';
// result
// ['ก', 'ข', 'ฃ', 'ค', 'ฅ', 'ฆ', 'ง', 'จ', 'ฉ', 'ช', 'ซ', 'ฌ', 'ญ', 'ฎ', 'ฏ', 'ฐ', 'ฑ', 'ฒ', 'ณ', 'ด', 'ต', 'ถ', 'ท', 'ธ', 'น', 'บ', 'ป', 'ผ', 'ฝ', 'พ', 'ฟ', 'ภ', 'ม', 'ย', 'ร', 'ฤ', 'ล', 'ฦ', 'ว', 'ศ', 'ษ', 'ส', 'ห', 'ฬ', 'อ', 'ฮ', 'ฯ', 'ะ', 'ั', 'า', 'ำ', 'ิ', 'ี', 'ึ', 'ื', 'ุ', 'ู', 'ฺ', '฿', 'เ', 'แ', 'โ', 'ใ', 'ไ', 'ๅ', 'ๆ', '็', '่', '้', '๊', '๋', '์', 'ํ', '๎', '๏', '๐', '๑', '๒', '๓', '๔', '๕', '๖', '๗', '๘', '๙', '๚', '๛'];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment