Arrays, also known as vectors, are widely used in programming to solve logical problems, often related to processing information in queue, stack or list.


An array consists of different positions that may be accessed via the respective command, which indicates the position by name or number.

By definition, the array is nothing more than a mathematical data structure, a pattern where the values ​​can be stored in rows and columns. This way you can organize the data and use them later.



The creation of an array in PHP can be done in two ways. In the first example we have an array being created using the array () function without the indication of the constructor:

<? Php

Vet $ = array ();

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

$ Vet [‘Phone’] = “11-33224555”;

$ Vet [‘Balance’] = 90,000;


Note that each position of the array is determined by a name that describes the stored value and the stored value that is assigned to the respective position.

This structure is widely used in functions that return database queries. Each position of the array is indicated with the name of the column.

In the next example we have a different situation:


$ Ar1 = array (‘value1’, ‘value2’, “value3”, “value x ‘);

print_r ($ ar1);?>



To use the function builder, each position receiveS Na indicator number and the stored value will be then rescued as follows:

ar1 [0] = value1

ar1 [1] = value2

ar1 [2] = value3

ar1 [3] = value x

The first position of the array will always be the zero position. Therefore, when one rescues the information you need to consider this item.

The use of the repetition structure is often used when it is necessary to go through an array in order to manipulate their values. In the following example, let’s go a four-position array, printing on screen the value of each position.

<? Php

$ Ar1 = array (‘value1’, ‘value2’, “value3”, “value x ‘);

for ($ var = 0; $ var <4; ++ $ var)


echo ($ ar1 [$ var] “.”);



The zero position until the three position, all values ​​will be printed on screen sequentially. It is important to be alert to stop parameter since, when accessing a non-existent position, the system will return an error advising that could not perform the action and the function will no longer run.

You might also like…

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

Disabling autofill and autocomplete Chrome browser in login screens

Hello, here I want to show an alternative to disable the autofill and autocomplete of the chrome bro...

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.