Edit wording/examples on PHP array documentation (#29885)

This commit is contained in:
exiam
2018-12-17 05:50:57 +01:00
committed by Randell Dawson
parent 9e1be6b7eb
commit 68c5a2e4e8

View File

@ -8,7 +8,7 @@ An array can be thought of as a collection of items.
## Syntax ## Syntax
An array is defined by array(), or []. An array is defined by `array()`, or `[]`.
An example of an array in each style can be seen below: An example of an array in each style can be seen below:
@ -16,13 +16,14 @@ An example of an array in each style can be seen below:
<?php <?php
$bikes = array('Suzuki','BMW','Yamaha'); $bikes = array('Suzuki','BMW','Yamaha');
```
```php // OR
<?php
$bikes = ['Suzuki', 'BMW', 'Yamaha']; $bikes = ['Suzuki', 'BMW', 'Yamaha'];
``` ```
## Associative array (key => value)
PHP arrays can store more than one type of value at a time: PHP arrays can store more than one type of value at a time:
``` ```
<?php <?php
@ -32,8 +33,6 @@ $arr = array('Suzuki', 3.1415, false, -273);
As you can see there is a string, a float number, a boolean valuea and an integer number. As you can see there is a string, a float number, a boolean valuea and an integer number.
## Key => Value
Arrays can also be defined with named keys, as shown below: Arrays can also be defined with named keys, as shown below:
```php ```php
@ -82,7 +81,7 @@ echo 'I like '. $bikes['not my favorite'];
Would produce the following output: Would produce the following output:
``` ```
I like BWM I like Yamaha
``` ```
## Multidimensional Array ## Multidimensional Array