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…

Scriptcase & Web Services

This time I will explain how to work with web services inside the Scriptcase, directly with PHP and...

More updates in 9.4 version

Recently version 9.4 was released bringing a new design concept to the generated applications of Sc...

Taking a look at version 9.4

Scriptcase released its version 9.4, and this one brings many interesting news, specially regarding...

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.