Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
2
Task/Reverse-a-string/PHP/reverse-a-string-1.php
Normal file
2
Task/Reverse-a-string/PHP/reverse-a-string-1.php
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
// Will split every Unicode character to array, reverse array and will convert it to string.
|
||||
join('', array_reverse(preg_split('""u', $string, -1, PREG_SPLIT_NO_EMPTY)));
|
||||
1
Task/Reverse-a-string/PHP/reverse-a-string-2.php
Normal file
1
Task/Reverse-a-string/PHP/reverse-a-string-2.php
Normal file
|
|
@ -0,0 +1 @@
|
|||
implode('', array_reverse(mb_str_split($string)));
|
||||
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)); // 👋👦🏻
|
||||
1
Task/Reverse-a-string/PHP/reverse-a-string-4.php
Normal file
1
Task/Reverse-a-string/PHP/reverse-a-string-4.php
Normal file
|
|
@ -0,0 +1 @@
|
|||
strrev($string);
|
||||
Loading…
Add table
Add a link
Reference in a new issue