[ Prev ]
2022-09-26

-- Sep 21 In-Class Exercise Thread
<? php
    function reverse_and_capitalize($str) {
        $words = explode(" ", $str);
        for ($i = count($words) - 1; $i >= 0; $i--) {
            echo(ucfirst($words[$i]) . " ");
        }
    }
?>
<? php function reverse_and_capitalize($str) { $words = explode(" ", $str); for ($i = count($words) - 1; $i >= 0; $i--) { echo(ucfirst($words[$i]) . " "); } } ?>

-- Sep 21 In-Class Exercise Thread
<?php
 function reverse($str)
 {
   $str_arr = explode(" ", $str);
   for($a = count($str_arr) -1; $a>=0; $a--)
   {
     echo ucfirst($str_arr[$a])," ";
   }
 }
<?php function reverse($str) { $str_arr = explode(" ", $str); for($a = count($str_arr) -1; $a>=0; $a--) { echo ucfirst($str_arr[$a])," "; } }

-- Sep 21 In-Class Exercise Thread
<? php function string_reverse($str) {
    $str2 = explode(" ", $str);
    $str3 = array_reverse($str2, " ");
    echo ucfirst($str3);
}
<? php function string_reverse($str) { $str2 = explode(" ", $str); $str3 = array_reverse($str2, " "); echo ucfirst($str3); }

-- Sep 21 In-Class Exercise Thread
<?php $sentence = "the quick brown fox"; reverse_uppercase($sentence);
function reverse_uppercase($sentence)
    {
        $str_array = explode(" ", $sentence);
        for ($x = count($str_array)-1; $x >= 0; $x--) {
            print strtoupper($str_array[$x][0]).substr($str_array[$x], 1)." ";
        }
    }
    
?>
(Edited: 2022-09-26)
<?php $sentence = "the quick brown fox"; reverse_uppercase($sentence); function reverse_uppercase($sentence) { $str_array = explode(" ", $sentence); for ($x = count($str_array)-1; $x >= 0; $x--) { print strtoupper($str_array[$x][0]).substr($str_array[$x], 1)." "; } } ?>

-- Sep 21 In-Class Exercise Thread
<?php function reverseStr($str) {
        $arr = explode(" ", $str);
	$arrReverse = join(array_reverse($arr), " ");
	echo ucwords($arrReverse);
} reverseStr("This is reversed haha");
<?php function reverseStr($str) { $arr = explode(" ", $str); $arrReverse = join(array_reverse($arr), " "); echo ucwords($arrReverse); } reverseStr("This is reversed haha");

-- Sep 21 In-Class Exercise Thread
    $str = "the quick brown fox";
    function reverse_and_capitalize($string)
    {
    $array = explode(" ", $string);
    $reversearray = array_reverse($array);
    $newstring = implode(" ", $reversearray);
    $capitalnewstring  = ucwords($newstring);
    echo $capitalnewstring;
    }
    reverse_and_capitalize($str);
$str = "the quick brown fox"; function reverse_and_capitalize($string) { $array = explode(" ", $string); $reversearray = array_reverse($array); $newstring = implode(" ", $reversearray); $capitalnewstring = ucwords($newstring); echo $capitalnewstring; } reverse_and_capitalize($str);
2022-09-27

-- Sep 21 In-Class Exercise Thread
<?php function reverse_cap_words($string) {
   $words = explode(" ", $string);
   $new_str = join(array_reverse($words), " ");
   echo ucwords($new_str);
        
} ?>
<?php function reverse_cap_words($string) { $words = explode(" ", $string); $new_str = join(array_reverse($words), " "); echo ucwords($new_str); } ?>
2022-10-03

-- Sep 21 In-Class Exercise Thread
    <?php
        $string = "the quick brown fox";
        function reverse_cap($string){
            $arr = explode(" ", $string);
            for($e = count($arr) - 1; $e >= 0; $e--){
                print(ucfirst($arr[$e]) . " ") ;
            }
        }
        reverse_cap($string);
    ?>
<?php $string = "the quick brown fox"; function reverse_cap($string){ $arr = explode(" ", $string); for($e = count($arr) - 1; $e >= 0; $e--){ print(ucfirst($arr[$e]) . " ") ; } } reverse_cap($string); ?>
X