3v4l.org

run code in 300+ PHP versions simultaneously
<?php /* * By Darien Hager, Jan 2007... Use however you wish, but please * please give credit in source comments. * * Change "UTF-8" to whichever encoding you are expecting to use. */ function ords_to_unistr($ords, $encoding = 'UTF-8') { // Turns an array of ordinal values into a string of unicode characters $str = ''; for ($i = 0; $i < count($ords); $i++) { // Pack this number into a 4-byte string // (Or multiple one-byte strings, depending on context.) $v = $ords[$i]; $str .= pack("N",$v); } $str = mb_convert_encoding($str,$encoding,"UCS-4BE"); return($str); } function unistr_to_ords($str, $encoding = 'UTF-8') { // Turns a string of unicode characters into an array of ordinal values, // Even if some of those characters are multibyte. $str = mb_convert_encoding($str,"UCS-4BE",$encoding); $ords = array(); // Visit each unicode character for ($i = 0; $i < mb_strlen($str,"UCS-4BE"); $i++) { // Now we have 4 bytes. Find their total // numeric value. $s2 = mb_substr($str,$i,1,"UCS-4BE"); $val = unpack("N",$s2); $ords[] = $val[1]; } return($ords); } function alphabet($firstCharacter = 'A', $lastCharacter = 'Z') { $firstCharacterValue = unistr_to_ords($firstCharacter)[0]; $lastCharacterValue = unistr_to_ords($lastCharacter)[0]; if ($firstCharacterValue < $lastCharacterValue) { for ($character = $firstCharacterValue; $character <= $lastCharacterValue; ++$character) { yield ords_to_unistr(array($character)); }; } else { for ($character = $firstCharacterValue; $character >= $lastCharacterValue; --$character) { yield ords_to_unistr(array($character)); }; } } foreach (alphabet('ا', 'ی') as $letter) { echo $letter, PHP_EOL; }
Output for git.master, git.master_jit, rfc.property-hooks
ا ب ة ت ث ج ح خ د ذ ر ز س ش ص ض ط ظ ع غ ػ ؼ ؽ ؾ ؿ ـ ف ق ك ل م ن ه و ى ي ً ٌ ٍ َ ُ ِ ّ ْ ٓ ٔ ٕ ٖ ٗ ٘ ٙ ٚ ٛ ٜ ٝ ٞ ٟ ٠ ١ ٢ ٣ ٤ ٥ ٦ ٧ ٨ ٩ ٪ ٫ ٬ ٭ ٮ ٯ ٰ ٱ ٲ ٳ ٴ ٵ ٶ ٷ ٸ ٹ ٺ ٻ ټ ٽ پ ٿ ڀ ځ ڂ ڃ ڄ څ چ ڇ ڈ ډ ڊ ڋ ڌ ڍ ڎ ڏ ڐ ڑ ڒ ړ ڔ ڕ ږ ڗ ژ ڙ ښ ڛ ڜ ڝ ڞ ڟ ڠ ڡ ڢ ڣ ڤ ڥ ڦ ڧ ڨ ک ڪ ګ ڬ ڭ ڮ گ ڰ ڱ ڲ ڳ ڴ ڵ ڶ ڷ ڸ ڹ ں ڻ ڼ ڽ ھ ڿ ۀ ہ ۂ ۃ ۄ ۅ ۆ ۇ ۈ ۉ ۊ ۋ ی

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
176.05 ms | 406 KiB | 5 Q