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