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.


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


$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:


$vet= array();

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

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

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

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



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:


$vet= array();

$vet[0][1]= 10;

$vet[0][2]= 20;


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


$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.


You might also like…

Scriptcase uses the MVC template?

Maybe you might have thought about this at some point, “Scriptcase uses the MVC templates?" Well, ...

How to implement A2F using Own Development in NodeJS in a Scriptcase application

A2F using Own Development in NodeJS A2F: In a previous article, we talked about Swivel as an extern...

Specialists or generalists, who gets a better advantage by using Scriptcase?

Hey there! Today  we will figure what are the ideal profiles for those who wish to take advantage o...

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 Learn more about our Privacy Police.