STAY INFORMED
following content serves as a personal note and may lack complete accuracy or certainty.

Minimal-Mistakes instruction
Useful vscode Shortcut Keys
Unix Commands
npm Commands
Vim Commands
Git Note
Useful Figma Shortcut Keys

less than 1 minute read

functions

usually recommended to save functions in inc/utils/

function countItemsInArray(Array $arrayToCount, int &$proposedCount) : bool{
    $itemCount = count($arrayToCount);
    if ($itemCount == $proposedCount){
        return true;
    }
    else{
        return false;
    }

}
require_once("inc/util.inc.php"); // import
$proposedCount = 4;
$carBrands = array("Volvo", "Mercedes", "Ford", "Honda");

echo countItemsInArray($carBrands, $proposedCount) . "\n"; // 1(true)
echo $proposedCount; // 4

Sample array of numbers

<?php

$numbers = array(5, 2, 8, 1, 9);

// Custom comparison function for sorting in ascending order
function customSort($a, $b) {
    if ($a == $b) {
        return 0;
    }
    return ($a < $b) ? -1 : 1;
}

// Use usort() with the custom comparison function
usort($numbers, "customSort");

// Output the sorted array
print_r($numbers);

Array
(
    [0] => 1
    [1] => 2
    [2] => 5
    [3] => 8
    [4] => 9
)
?>

Tags:

Categories:

Updated: