belongs to collection: PHP Array Programs
Syntax:
array(key1=>value1, key2=>value2, key3=>value3, ...);
Example:
In this example, we are creating an associative array, printing the values: 1) Using keys, and 2) Printing complete array with keys & values
<?php //creating student array with keys & values $std = array('id' => "101", 'name' => "Amit", 'course' => "B.Tech"); //printing elemenets print ("std elements...\n"); print ("Id = " . $std['id'] . " Name = " . $std['name'] . " Course = " . $std['course']); //printing array using for each loop //printing complete array print ("std...\n"); print_r($std); ?>
Output
std elements... Id = 101 Name = Amit Course = B.Techstd... Array ( [id] => 101 [name] => Amit [course] => B.Tech )
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
Example:
In this example, we are creating an associative array, printing the values: 1) Using keys, and 2) Printing complete array with keys & values
Output
need an explanation for this answer? contact us directly to get an explanation for this answer