Created
July 25, 2017 14:59
-
-
Save HoangPV/6506b01fb1e20359b32e9478610e62a3 to your computer and use it in GitHub Desktop.
Take a string, then for every words we reverse the order of character.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
echo strRevCha("Take a string, then for every words we reverse the order of character."); | |
/** | |
* Take a string, then for every words we reverse the order of character. | |
* | |
* @param String $str a string | |
* @return String|null $strOutput | |
* @author Phan Vu Hoang <vu-hoang.phan@ekino.com> | |
*/ | |
function strRevCha($str) { | |
$strOutput = []; | |
$strAr = explode(' ', $str); | |
foreach ( $strAr as $s) { | |
$strOutput[] = strrev($s); | |
} | |
return implode(" ", $strOutput); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment