mirror of
https://github.com/kamranahmedse/developer-roadmap.git
synced 2025-08-22 08:53:01 +02:00
Update code example in PHP roadmap (#8973)
This commit is contained in:
committed by
GitHub
parent
4037e3bb31
commit
bc4e29521b
@@ -3,15 +3,15 @@
|
||||
Associative arrays in PHP are a type of array that uses named keys instead of numeric ones. This provides a more human-readable way to store data where each value can be accessed by its corresponding string key. An example of an associative array could be storing names as keys and their corresponding ages as values. Here's a brief example:
|
||||
|
||||
```php
|
||||
$ages = array(
|
||||
$ages = [
|
||||
"Peter" => 35,
|
||||
"John" => 42,
|
||||
"Mary" => 27
|
||||
);
|
||||
];
|
||||
```
|
||||
|
||||
In this case, to find out John's age, you would simply use `echo $ages['John']` where 'John' is the key. Associative arrays are also easy to loop through using the `foreach` construct.
|
||||
|
||||
Visit the following resources to learn more:
|
||||
|
||||
- [@official@PHP Documentation - Associative Arrays](https://www.php.net/manual/en/language.types.array.php)
|
||||
- [@official@PHP Documentation - Associative Arrays](https://www.php.net/manual/en/language.types.array.php)
|
||||
|
@@ -5,10 +5,10 @@ Indexed arrays in PHP store values that are accessed through numerical indexes,
|
||||
Here's an Example:
|
||||
|
||||
```php
|
||||
$books = array("The Great Gatsby", "Moby Dick", "To Kill a Mockingbird");
|
||||
$books = ["The Great Gatsby", "Moby Dick", "To Kill a Mockingbird"];
|
||||
echo $books[0]; //Outputs "The Great Gatsby"
|
||||
```
|
||||
|
||||
Visit the following resources to learn more:
|
||||
|
||||
- [@official@Indexed Arrays](https://www.php.net/manual/en/language.types.array.php)
|
||||
- [@official@Indexed Arrays](https://www.php.net/manual/en/language.types.array.php)
|
||||
|
@@ -1,17 +1,17 @@
|
||||
# Multi-dimensional Arrays
|
||||
|
||||
Multi-dimensional arrays in PHP are a type of array that contains one or more arrays. Essentially, it's an array of arrays. This allows you to store data in a structured manner, much like a table or a matrix. The fundamental idea is that each array value can, in turn, be another array. For instance, you can store information about various users, where each user (a primary array element) contains several details about them (in a secondary array like email, username etc.).
|
||||
Multi-dimensional arrays in PHP are a type of array that contains one or more arrays. Essentially, it's an array of arrays. This allows you to store data in a structured manner, much like a table or a matrix. The fundamental idea is that each array value can, in turn, be another array. For instance, you can store information about various users, where each user (a primary array element) contains several details about them (in a secondary array like email, username etc.).
|
||||
|
||||
Here's an example:
|
||||
|
||||
```php
|
||||
$users = array(
|
||||
array("John", "john@example.com", "john123"),
|
||||
array("Jane", "jane@example.com", "jane123"),
|
||||
array("Doe", "doe@example.com", "doe123")
|
||||
);
|
||||
$users = [
|
||||
["John", "john@example.com", "john123"],
|
||||
["Jane", "jane@example.com", "jane123"],
|
||||
["Doe", "doe@example.com", "doe123"]
|
||||
];
|
||||
```
|
||||
|
||||
Visit the following resources to learn more:
|
||||
|
||||
- [@official@Multi-dimensional Arrays](https://www.php.net/manual/en/language.types.array.php)
|
||||
- [@official@Multi-dimensional Arrays](https://www.php.net/manual/en/language.types.array.php)
|
||||
|
Reference in New Issue
Block a user