1
1
mirror of https://github.com/namibia/awesome-cheatsheets.git synced 2024-12-22 01:58:54 +00:00

Merge branch 'master' of github.com:LeCoupa/awesome-cheatsheets

This commit is contained in:
Julien Le Coupanec 2020-07-03 14:29:08 +02:00
commit f8eb132e2f

View File

@ -11,6 +11,33 @@ echo ""; // Print a string or type that can be made into a string(I.E int, float
print_r($arr); // Print anything, with type hints for array's and object's
var_dump($arr); // Print anything, with type hints for any value and sizes
/**
* Declaring an Array
*/
// Indexed Array
$arr = array("John", "Doe", "Lorem", "Ipsum");
// Associative Array
$arr = array("John"=>"10", "Doe"=>"200", "Doe"=>"3000", "Ipsum"=>"40000");
// Multidimensional Arrays
$arr = array (
array("John",100,180),
array("Doe",150,130),
array("Lorem",500,200),
array("Ipsum",170,150)
);
/**
* Sorting an Array
*/
sort($arr); // Sort arrays in ascending order.
rsort($arr); // Sort arrays in descending order.
asort($arr); // Sort associative arrays in ascending order, according to the value.
ksort($arr); // Sort associative arrays in ascending order, according to the key.
arsort($arr); // Sort associative arrays in descending order, according to the value.
krsort($arr); // Sort associative arrays in descending order, according to the key.
/**
* Ways of looping
*/