i am tring to reverse string of each word here is my logic can any body check and make it right where i am getting wrong must be appreciated i know i am missing some thing little bit. must be appreciate if make this code and logic write.
code:-
<?php
$a = "i am getting late";
$count = 0;
$Reversestring = "";
while(isset($a[$count]))
{
if($a[$count] != '')
{
echo $a[$count];
$catchWord .= $a[$count];
$count++;
}else{
die($catchWord);
$Reversestring .= reverseWord($catchWord);
}
}
echo $Reversestring;
function reverseWord($word)
{
$revWord;
for($i = str_word_count($word) ; $i > 0; $i--)
{
$revWord = $word[$i];
}
return $revWord;
?>