Sunday, 9 June 2013

Give multi-dimensional array example in php?


Example -

 In below example, we have used multi-dimensional array to store information about different employees

Code and Syntax

<?php
// A two-dimensional array
$emp = array
   (
   array("emp1",22,9600),
   array("emp2",30,5944),
     );
  
echo $emp[0][0].": age: ".$emp[0][1].". salary: ".$emp[0][2]."<br>";

?>

Explanation
We have printed the age and salary of first employee. So we have 2 arrays inside $emp array. We access elements in array using C convention.

 For more php questions and answers, dumps,tutorials for beginners and experienced people visit http://www.top-php-interview-questions.blogspot.in  If you find any errors while executing this program, you can make your comments or mail me at reply2sagar@gmail.com


















No comments:

Post a Comment