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

Commit

Permalink
Added 2 code snippets in php
Browse files Browse the repository at this point in the history
Added two code snippets in arrays.md:
-> Multi-dimensional arrays
-> Multi-dimensional associative arrays
  • Loading branch information
shah78677 committed Oct 8, 2019
1 parent 5559e8d commit 7086a54
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions source/snippets/php/arrays.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,34 @@ sort($array); //sort() function
$array = ["Car", "Bike", "Train"];

rsort($array); //rsort() function
```

### Multi-dimensional arrays
```php
$students = array(
//Student Name, Age and Behaviour
array('Jack', 14, 'Good'),
array('Mary', 13, 'Good'),
);
//print_r($students)
```

### Multi-dimensional associative arrays
```php
$marks = array(
//Name of student is key
"Jack" => array(
//key-value pairs
"Maths" => 95,
"Science" => 84,
"History" => 48,
),

"Mary" => array(
"Maths" => 78,
"Science" => 76,
"History" => 64,
),
);
//print_r($marks)
```

0 comments on commit 7086a54

Please sign in to comment.