Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Apprendre Creating Arrays | Tableaux
Introduction à PHP

Creating Arrays

Arrays in PHP are a powerful tool for storing and managing data.

An array is a variable that can hold multiple values at once. They can contain data of any type: numbers, strings, objects, other arrays, etc.

Creating Arrays

main.php

main.php

1
$numbers = [1, 2, 3, 4, 5];

Explanation of Logic and Syntax:

1747f074-ff16-43b2-8634-7a38c3e8d0a0
  1. Here, we declare a variable named $numbers;

  2. The = operator is used to assign a value to the variable;

  3. The array is created using square brackets []. Inside the brackets, we list the array elements separated by commas. In this example, we have created an array with the numbers: 1, 2, 3, 4, 5.

Tout était clair ?

Comment pouvons-nous l'améliorer ?

Merci pour vos commentaires !

Section 4. Chapitre 1
single

single

Creating Arrays

Glissez pour afficher le menu

Arrays in PHP are a powerful tool for storing and managing data.

An array is a variable that can hold multiple values at once. They can contain data of any type: numbers, strings, objects, other arrays, etc.

Creating Arrays

main.php

main.php

1
$numbers = [1, 2, 3, 4, 5];

Explanation of Logic and Syntax:

1747f074-ff16-43b2-8634-7a38c3e8d0a0
  1. Here, we declare a variable named $numbers;

  2. The = operator is used to assign a value to the variable;

  3. The array is created using square brackets []. Inside the brackets, we list the array elements separated by commas. In this example, we have created an array with the numbers: 1, 2, 3, 4, 5.

Tâche

Glissez pour commencer à coder

Fill in the blanks in the code to create an array with three specific strings 'apple', 'banana', 'cherry' inside square brackets. Elements should be in exactly the same sequence as shown in the example above.

Solution

Switch to desktopPassez à un bureau pour une pratique réelleContinuez d'où vous êtes en utilisant l'une des options ci-dessous
Tout était clair ?

Comment pouvons-nous l'améliorer ?

Merci pour vos commentaires !

Section 4. Chapitre 1
single

single

Demandez à l'IA

expand

Demandez à l'IA

ChatGPT

Posez n'importe quelle question ou essayez l'une des questions suggérées pour commencer notre discussion

some-alt