[ Prev ]
2022-09-22

-- Sep 21 In-Class Exercise Thread
<?php
function reverseCap($str) {
    $words = explode(" ", $str);
    for ($i = count($words) - 1; $i >= 0; $i--) {
        $words[$i] = strtoupper($words[$i][0]).substr($words[$i], 1);
    }
    krsort($words);
    $str = implode(" ", $words);
    echo $str;
}
$str = "the quick brown fox";
reverseCap($str);
(Edited: 2022-09-22)
<?php function reverseCap($str) { $words = explode(" ", $str); for ($i = count($words) - 1; $i >= 0; $i--) { $words[$i] = strtoupper($words[$i][0]).substr($words[$i], 1); } krsort($words); $str = implode(" ", $words); echo $str; } $str = "the quick brown fox"; reverseCap($str);

-- Sep 21 In-Class Exercise Thread
<?php
function reverse($string){
    $strArray = explode(" ", $string);
    $res;
    for($i = count($strArray)-1; $i >= 0; $i--){
        $res = strtoupper(substr($strArray[$i], 0, 1)).substr($strArray[$i], 1)." ";
        echo $res;
    }
}
$s = "the quick brown fox";
reverse($s);
<?php function reverse($string){ $strArray = explode(" ", $string); $res; for($i = count($strArray)-1; $i >= 0; $i--){ $res = strtoupper(substr($strArray[$i], 0, 1)).substr($strArray[$i], 1)." "; echo $res; } } $s = "the quick brown fox"; reverse($s);

-- Sep 21 In-Class Exercise Thread
<?php function str_reverse($str) {
        $arr = explode(" ", $str);
	$str_r = join(array_reverse($arr), " ");
	echo ucwords($str_r);
        
} str_reverse("the quick brown fox");
(Edited: 2022-09-23)
<?php function str_reverse($str) { $arr = explode(" ", $str); $str_r = join(array_reverse($arr), " "); echo ucwords($str_r); } str_reverse("the quick brown fox");
2022-09-23

-- Sep 21 In-Class Exercise Thread
 <?php
$ex_str = "the quick brown fox";
function reverseCap($str) {
    $arr = explode(" ", $str);
    $length = count($arr);
    for ($i = 0; $i < $length; $i++) {
        $arr[$i] = ucfirst($arr[$i]);
    }
    $reversed_arr = implode(" ", $arr);
    echo $reversed_arr;
}
reverseCap($ex_str); ?>
<?php $ex_str = "the quick brown fox"; function reverseCap($str) { $arr = explode(" ", $str); $length = count($arr); for ($i = 0; $i < $length; $i++) { $arr[$i] = ucfirst($arr[$i]); } $reversed_arr = implode(" ", $arr); echo $reversed_arr; } reverseCap($ex_str); ?>
2022-09-25

-- Sep 21 In-Class Exercise Thread
 <?php
function reverse($str) {
    $strArr = explode(" ", $str);
    for ($i = count($strArr) - 1; $i >= 0; $i--) {
        $strArr[$i] = strtoupper($strArr[$i][0]).substr($strArr[$i], 1);
    }
    echo $str;
} $str = "the quick brown fox";
reverse($str);
(Edited: 2022-09-25)
<?php function reverse($str) { $strArr = explode(" ", $str); for ($i = count($strArr) - 1; $i >= 0; $i--) { $strArr[$i] = strtoupper($strArr[$i][0]).substr($strArr[$i], 1); } echo $str; } $str = "the quick brown fox"; reverse($str);

-- Sep 21 In-Class Exercise Thread
<?php
    function reverseString($str) {
        return array_reverse(explode(" ", ucwords($str)));
    }
?>
<?php function reverseString($str) { return array_reverse(explode(" ", ucwords($str))); } ?>

-- Sep 21 In-Class Exercise Thread
<?php function reverseStr($str) {
        $arr = explode(" ", $str);
	$str_reverse = join(array_reverse($arr), " ");
	echo ucwords($str_reverse);
        
} reverseStr("the quick brown fox");
(Edited: 2022-09-26)
<?php function reverseStr($str) { $arr = explode(" ", $str); $str_reverse = join(array_reverse($arr), " "); echo ucwords($str_reverse); } reverseStr("the quick brown fox");

-- Sep 21 In-Class Exercise Thread
<?php
    $arr = ["the", "quick", "brown", "fox"];
    $arrEnd = end($arr);
    for($i = count($arr) - 1; $i >= 0; $i--) {
        echo ucfirst($arr[$i]);
    }
?>
<?php $arr = ["the", "quick", "brown", "fox"]; $arrEnd = end($arr); for($i = count($arr) - 1; $i >= 0; $i--) { echo ucfirst($arr[$i]); } ?>

-- Sep 21 In-Class Exercise Thread
<?php function reverse($str) {
    $words = explode(" ", $str);
    krsort($words);
    foreach($words as $value){
        echo ucwords($value)," ";
    }
} $stence = "the quick brown fox";
reverse($stence); ?>
(Edited: 2022-09-26)
<?php function reverse($str) { $words = explode(" ", $str); krsort($words); foreach($words as $value){ echo ucwords($value)," "; } } $stence = "the quick brown fox"; reverse($stence); ?>

-- Sep 21 In-Class Exercise Thread
function reverseString($str) {
    $words = explode(" ", $str);
    for ($i = count($words) - 1; $i >= 0; $i--) {
        echo ucfirst($words[$i]), " ";
    }
    echo "\n";
}
function reverseString($str) { $words = explode(" ", $str); for ($i = count($words) - 1; $i >= 0; $i--) { echo ucfirst($words[$i]), " "; } echo "\n"; }
[ Next ]
X