abc

Share This blog with your friends, so that we can improve more & more . our aim is to easy & simple way of learning.

12/15/2020

What is and How to create PHP array

 array - store multiple value into single variable -

three types of array -  index, associative, Multidimensional array.


1) index array - store value into variable in curley and quoted form.


for example - 


$name = {'drip','pipe','sprinkler'};

echo $name[0] . '  '.$name[2];


2) Associative array - associate some value 


let us see example, 

$price = array("mobile"=>"8500","fan"=>"4500","light"=>"300"); 

echo $price['light'];


3) Multidimensional array - multiple checkup done


for example we have two for loop which check in $emp array and get respective value


echo $emp[0][0] ouput is 1,"sonoo",400000

<?php    

$emp = array  

  (  

  array(1,"sonu",4000),  

  array(2,"monu",5000),  

  array(3,"pinu",7000)  

  );  

  

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

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

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

  }  

  echo "<br/>";  

}  

?>   


No comments:

Post a Comment

An Introduction to the Laravel Framework: What It Is and Why You Should Use It

  If you're a PHP developer looking for a modern, efficient, and powerful framework to build web applications, look no further than Lara...