Programming using arrays is very common. They are variables that can store a large number of information and can be easily handled and used in the programming.

ARRAYS

The declaration of an array in PHP is given as follows:

<?php

$vet= array();

$vet[0]= 10;

$vet[1]= 20;

?>

Each space in the array will store the indicated number as shown in the example, using indices starting at zero is possible to store each data. It is important to take into consideration that the array will have its size defined according to the number of elements that are placed on it.

A major advantage of arrays in PHP is the characteristic associative. You do not need to declare a certain position, it can be referenced by a string and store any type of value that is required. Check out the example below:

<?php

$vet= array();

$vet[‘Name’]= “Luiza”;

$vet[‘Phone’]= “11-33224555″;

$vet[‘Value’]= 90,000;

echo ($vet[‘Name’]. ” ” .$vet[‘Phone’]. ” ” .$vet[‘Value’]);

?>

MULTIDIMENSIONAL ARRAYS

To declare and manipulate multidimensional arrays using the same format for the declaration of vectors, the difference is that declares more than one position, as shown below:

<?php

$vet= array();

$vet[0][1]= 10;

$vet[0][2]= 20;

?>

You can still use multidimensional arrays to store even more data.

<?php

$vet= array();

$vet[0][0][1]= 10;

$vet[0][0][2]= 20;

?>

The operation of arrays and multidimensional arrays in PHP is critical to the everyday activities of a programmer, with these resources it is possible to manipulate and validate data much faster and logic thus saving processing time.

php

You might also like…

PROCESAMIENTO AJAX EN SCRIPTCASE

Ajax en los formularios de Scriptcase puede usarse para recargar un campo de tipo de select basado e...

IMPORTAR IMAGENES DE LA BASE DE DATOS Y UTILIZAR CLASES DE BOOSTRAP

Como muchas personas ya saben, Bootstrap es una biblioteca de front-end libre y de código abierto p...

TENDENCIAS DE DESARROLLO WEB PARA 2017

Usted verá en este post tendencias para 2017 en Diseño Web, en el medio digital y en el desarrollo...

Comment this post

Get new posts, resources, offers and more each week.

We will use the information you provide to update you about our Newsletter and Special Offers. You can unsubscribe any time you want by clinck in a link in the footer of any email you receive from us, or by contacting us at sales@scriptcase.net. Learn more about our Privacy Police.