Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
21
Task/Reverse-a-string/PHP/reverse-a-string-3.php
Normal file
21
Task/Reverse-a-string/PHP/reverse-a-string-3.php
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
$a = mb_convert_encoding('👦🏻👋', 'UTF-8', 'HTML-ENTITIES'); // 👦🏻👋
|
||||
|
||||
function str_to_array($string)
|
||||
{
|
||||
$length = grapheme_strlen($string);
|
||||
$ret = [];
|
||||
|
||||
for ($i = 0; $i < $length; $i += 1) {
|
||||
|
||||
$ret[] = grapheme_substr($string, $i, 1);
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
function utf8_strrev($string)
|
||||
{
|
||||
return implode(array_reverse(str_to_array($string)));
|
||||
}
|
||||
|
||||
print_r(utf8_strrev($a)); // 👋👦🏻
|
||||
Loading…
Add table
Add a link
Reference in a new issue