डिप्लोमा इन ऑफिस मैनेजमेंट एण्ड अकाउटिंग

डिप्लोमा इन ऑफिस मैनेजमेंट एण्ड अकाउटिंग

Full Stack Web Development with Laravel

Full Stack Web Development with Laravel

Affiliate Program

Affiliate Program

PHP arrays

Indexed array

$persons=["Aman", "Ajay", "Kamal"];

print indexed array

echo $persons[0];
echo $persons[1];
echo $persons[2];


looping indexed array using foreach

foreach($persons as $index=>$person){
echo "$index has value $person <br>";
}

Multidimensional array

$persons=[
["aman", 20, "delhi"],
["kamal", 20, "delhi"]
];

foreach loop over multidimensional array

foreach($persons as $person){
   foreach($person as $record){
         echo $record." ";
}
echo "<br>";
}

Associative array

$person=["name"=>"aman", "age"=>20, "isLogin"=>true];

foreach loop over associative array

foreach($person as $index=>$value){
   echo "$index has value $value <br>";
}
© 2016 - 2023, All Rights are Reserved.