Few code standards. Remove composer vendor folder
This commit is contained in:
19
solutions/other/reverseWords.php
Normal file
19
solutions/other/reverseWords.php
Normal file
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
function reverseWords(string $str): string
|
||||
{
|
||||
$words = explode(' ', $str);
|
||||
$words = array_reverse($words);
|
||||
return implode(' ', $words);
|
||||
}
|
||||
|
||||
function reverseWords2(string $str): string
|
||||
{
|
||||
$words = explode(' ', $str);
|
||||
foreach ($words as &$word) {
|
||||
$word = strrev($word);
|
||||
}
|
||||
return implode(' ', $words);
|
||||
}
|
||||
|
||||
echo reverseWords("The lazy dog") . PHP_EOL;
|
||||
echo reverseWords2("The lazy dog") . PHP_EOL;
|
Reference in New Issue
Block a user