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
PHP_2(array)
var_dump() is a PHP function that is used for debugging and displaying information about variables, arrays, or objects. It provides detailed information about the structure and type of a variable, helping developers understand the content and structure of their data during the development process.
explode
<?php
$fruits = "apples, bananas, pears, pluns";
$fruitBasket = explode(",", $fruits);
var_dump($fruitBasket);
/*
array(4) {
[0]=>
string(6) "apples"
[1]=>
string(8) " bananas"
[2]=>
string(6) " pears"
[3]=>
string(6) " pluns"
}*/
?>
simple array
<?php
$toppings = array(); // make it 2d array
$toppings = ["Cheese", "Pepperoni", "Anchovies"];
$toppings[] = "Corn"; // append
rsort($toppings); // reverse sort
var_dump($toppings);
/*
array(4) {
[0]=>
string(9) "Pepperoni"
[1]=>
string(4) "Corn"
[2]=>
string(6) "Cheese"
[3]=>
string(9) "Anchovies"
}
*/
print letters depending on the range
$letters = range('a', 'f');
for ($i = 0; $i < count($letters); $i++){
// re-assign
$letters[$i] = array($letters[$i], $i + 10);
}
var_dump($letters);
/* int(10)
}
[1]=>
array(2) {
[0]=>
string(1) "b"
[1]=>
int(11)
}
[2]=>
array(2) {
[0]=>
string(1) "c"
[1]=>
int(12)
}
[3]=>
array(2) {
[0]=>
string(1) "d"
[1]=>
int(13)
}
[4]=>
array(2) {
[0]=>
string(1) "e"
[1]=>
int(14)
}
[5]=>
array(2) {
[0]=>
string(1) "f"
[1]=>
int(15)
}
}
*/
?>
key value
<?php
$courses["key"] = "value";
$courses[] = "val1"; // this is considered key=0
$courses[] = "val2"; // this is considered key=1
asort($courses); // sorted by the values
ksort($courses); // sorted by the keys
arsort($courses); // sorted by the values, reverse
krsort($courses); // sorted by the keys, reverse
?>