From 9a210f53050fc8cb4252c4bedb605ced036623ba Mon Sep 17 00:00:00 2001 From: akhillllldev Date: Tue, 8 Oct 2019 19:38:05 +0530 Subject: [PATCH] Updated the Arrays section of PHP --- source/snippets/php/arrays.md | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/source/snippets/php/arrays.md b/source/snippets/php/arrays.md index 5a5c731..a4ddae6 100644 --- a/source/snippets/php/arrays.md +++ b/source/snippets/php/arrays.md @@ -13,8 +13,8 @@ Create new array in PHP // Usage $array = []; // recommended -$array = array(); -$array = ['foo' => 'bar']; +$array = array(); //array() function +$array = ['foo' => 'bar']; ``` ### Destructure arrays in PHP @@ -54,4 +54,27 @@ $array = [ ['c' => $c, 'a' => $a] = $array; +``` + +### Length of an array +```php +$array = ["Car", "Bike", "Train"]; + +count($array); //count() function + +``` + +### Sort an array in Ascending Order +```php +$array = ["Train", "Car", "Bike"]; + +sort($array); //sort() function + +``` + +### Sort an array in Descending Order +```php +$array = ["Car", "Bike", "Train"]; + +rsort($array); //rsort() function ``` \ No newline at end of file