Skip to content
This repository has been archived by the owner on Jul 20, 2023. It is now read-only.

Commit

Permalink
Merge pull request #36 from akhillllldev/feature/akhillllldev
Browse files Browse the repository at this point in the history
Updated the Arrays section of PHP
  • Loading branch information
rickwest authored Oct 8, 2019
2 parents c369265 + 9a210f5 commit 5559e8d
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions source/snippets/php/arrays.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
```

0 comments on commit 5559e8d

Please sign in to comment.