0% found this document useful (0 votes)
2 views1 page

array_in_php

The document explains arrays in PHP, which are special variables that can hold multiple values. It describes three types of arrays: indexed arrays, associative arrays, and multidimensional arrays, providing examples for each type. Indexed arrays use numeric indices, associative arrays store key-value pairs, and multidimensional arrays allow for tabular data storage.

Uploaded by

bejpapai
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views1 page

array_in_php

The document explains arrays in PHP, which are special variables that can hold multiple values. It describes three types of arrays: indexed arrays, associative arrays, and multidimensional arrays, providing examples for each type. Indexed arrays use numeric indices, associative arrays store key-value pairs, and multidimensional arrays allow for tabular data storage.

Uploaded by

bejpapai
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

ARRAY IN PHP

An array is an special variable which can hold more than one value at a time.

example: $laptop=array(“Asus”,” Lenevo ”);

There are three types of array:

1.Indexed arrays : PHP indexed array is an array which is represented by an index number by default. example : $size=array(“ big ”,” medium ”,” short”);

echo ” $size [0] ”;

2.Associative arrays : Associative arrays are used to store key value pairs.

<?php

$salary=array("Sonoo"=>"550000","Vimal"=>"250000","Ratan"=>"200000");

echo "Sonoo salary: ".$salary["Sonoo"]."<br/>";

echo "Vimal salary: ".$salary["Vimal"]."<br/>";

echo "Ratan salary: ".$salary["Ratan"]."<br/>";

?>

3. Multidimensional array: multidimensional array is also known as array of arrays, it allows you to store tabular data in an array.

<?php

$emp = array ( array(1,"sonoo",400000), array(2,"john",500000), array(3,"rahul",300000) );

for ($row = 0; $row < 3; $row++)

for ($col = 0; $col < 3; $col++) {

echo $emp[$row][$col]." "; }

echo "<br/>"; }

?>

You might also like