Associative Array in PHP

Program 1

<html>
<body>
<pre>
<center>
<?php

//    $myArray=array(10,20,30,40,"vivek",56.77);
//     foreach($myArray as $data)
//     {
//         echo $data;
//     }
   // Asscociative array
      $myid=array("id1"=>501,"id2"=>502,"id3"=>503,"id4"=>504);
      foreach($myid as $key=> $data)
      {
          echo "<br>".$key."=".$data;
      } 
//     //                  key          
//    //print_r($myid); 
//    //var_dump($myid);
//    echo $myid["id1"];
//    echo "<br>";
//    echo $myid["id2"];
//    echo "<br>";
//    echo $myid["id3"];
//    echo "<br>";
//    echo $myid["id4"];
//   $student=array("id"=>101,
//                           "name"=>"Rajesh Sharma",
//                           "age"=>23,
//                           "course"=>"Mtech" 
//                          );
//        echo $student["id"];
//        echo "<br>";
//        echo $student["name"];
//        echo "<br>";
//        echo $student["age"];
//        echo "<br>";
//        echo $student["course"];

?>
</center>
</pre>
</body>
</html>

 

courses

TechVidvan Team

TechVidvan Team provides high-quality content & courses on AI, ML, Data Science, Data Engineering, Data Analytics, programming, Python, DSA, Android, Flutter, full stack web dev, MERN, and many latest technology.

Leave a Reply

Your email address will not be published. Required fields are marked *