1
0
mirror of https://github.com/kamranahmedse/developer-roadmap.git synced 2025-08-23 01:13:03 +02:00

Update code example in PHP roadmap (#8973)

This commit is contained in:
Renato Francia Castillo
2025-08-01 10:34:31 -05:00
committed by GitHub
parent 4037e3bb31
commit bc4e29521b
3 changed files with 12 additions and 12 deletions

View File

@@ -3,11 +3,11 @@
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: 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 ```php
$ages = array( $ages = [
"Peter" => 35, "Peter" => 35,
"John" => 42, "John" => 42,
"Mary" => 27 "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. 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.

View File

@@ -5,7 +5,7 @@ Indexed arrays in PHP store values that are accessed through numerical indexes,
Here's an Example: Here's an Example:
```php ```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" echo $books[0]; //Outputs "The Great Gatsby"
``` ```

View File

@@ -5,11 +5,11 @@ Multi-dimensional arrays in PHP are a type of array that contains one or more ar
Here's an example: Here's an example:
```php ```php
$users = array( $users = [
array("John", "john@example.com", "john123"), ["John", "john@example.com", "john123"],
array("Jane", "jane@example.com", "jane123"), ["Jane", "jane@example.com", "jane123"],
array("Doe", "doe@example.com", "doe123") ["Doe", "doe@example.com", "doe123"]
); ];
``` ```
Visit the following resources to learn more: Visit the following resources to learn more: