free classified ads and leads
domain website price


Array In PHP

PHP

Array In PHP

 

PHP supports three types of arrays :

  1. Indexed arrays
  2. Associative arrays
  3. Multidimensional arrays

Index Arrays :

An indexed array stores values in sequential numeric indices, start from 0 . you can create an indexed array using the array() function or the [] shorthand syntax.

 

$country = array("India","USA","UK","UAE");

You can access the elements of an indexed array using their index :

echo $country[0];  // output “India”

echo $country[1];  // output “USA”

Associative Arrays:

An associative array stores values in Key-value pairs, where each key is a unique string identifier. you can create a n associative array using the array() function or the [] shorthand syntax.

$people=["name"=>"Manan","age"=>"25","mobile"=>"9878357855","email"=>"abc@domain.com"];

You can access the elements of an associative array using their key :

echo $people["name"];  // outputs is “Manan”

Multidimensional Arrays

A multidimensional array is an array of arrays, where each element can be an indexed or associative array. You can create a multidimensional array using nested array.

$men = [ 

["name"=>"Pawan", “age”=>20],

["name"=>"Manan", “age”=>30],

["name"=>"Kuldeep", “age”=>40] 

];

 

you can access the elements of a multidimensional array using multiple indices:

 

echo $men[0]["name"];  // output is Pawan


 

 

 

Bookmark and Share




Gallery

Related Topics

Comments



Submit Reviews:


(Enter the characters seen on the image below.)



Promotional Ads

Advertisement

Packers and movers in Mohali
Plot No 636, Near HP Gas Agency, Dariya, Chandigarh - 160101
Mohali

Submersible Sludge Pumps
18, shreenath Estate, cross road, nr. Nikol, nr. Sardar Patel Ring Road, Kathwada, Gujarat 382415
Ahmedabad

Bhakti Bird Proofing
House no.9479 durgamata tekdi vibhag, mahalaxmi nagar, City ambernath, Near durgamata temple. Pin Code-421501
Motilal Nagar Mumbai

Livonta Global Pvt.Ltd
1110, Colonnade, B/H Iscon Temple, Opp. Iscon BRTS Bus Stand
Iscon - Ambali Rd,
Ahmedabad

Brij Agnihotri & associates company secretaries
3454, 40D, Sector 40D, Chandigarh, 160036, India

JB Rock Bolts & SN BOLTS
10 A & B Industrial Area (at Vill. Nangal Jarialan)
Distt. Una Himachal Pradesh
Una

Govinda resorts Lonavala
Old Mumbai - Pune Hwy, Maval, Lonavala, Maharashtra 410405
Lonavla

Steelco Metal & Alloys
192 – Minara Mansion, Shop No.6, Sant Sena Maharaj Marg, 2nd Kumbharwada Lane, Mumbai, Maharashtra 400004
Mumbra Mumbai

Best Resorts in Dharamshala Amid the Misty Hills.
SATOBARI HILLS ROAD,MCLEODGANJ,
Dharamshala

Genius Global School
194 Anand Vihar Saproon, Solan, Himachal Pradesh
Ambala Cantt