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

Contenido del Curso

Introduction to PHP

Introduction to PHP

1. First Acquaintance
2. Variables and Data Types
3. Conditional Statements
4. Arrays
5. Loops

bookCreating 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

php

main

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

Explanation of Logic and Syntax:

  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.

Tarea
test

Swipe to show code editor

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.

Switch to desktopCambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones
¿Todo estuvo claro?

¿Cómo podemos mejorarlo?

¡Gracias por tus comentarios!

Sección 4. Capítulo 1
toggle bottom row

bookCreating 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

php

main

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

Explanation of Logic and Syntax:

  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.

Tarea
test

Swipe to show code editor

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.

Switch to desktopCambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones
¿Todo estuvo claro?

¿Cómo podemos mejorarlo?

¡Gracias por tus comentarios!

Sección 4. Capítulo 1
toggle bottom row

bookCreating 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

php

main

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

Explanation of Logic and Syntax:

  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.

Tarea
test

Swipe to show code editor

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.

Switch to desktopCambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones
¿Todo estuvo claro?

¿Cómo podemos mejorarlo?

¡Gracias por tus comentarios!

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

php

main

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

Explanation of Logic and Syntax:

  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.

Tarea
test

Swipe to show code editor

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.

Switch to desktopCambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones
Sección 4. Capítulo 1
Switch to desktopCambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones
We're sorry to hear that something went wrong. What happened?
some-alt