0

foreach loop in multidimensional array

hey all, I have an array $details = array( array( "roll_no" => "1", "name" => "Xyz"), array( "roll_no" => "2", "name" => "iyz"), array( "roll_no" => "3", "name" => "Xaz")); I would like to print name using the roll no. Eg: Localhost/test.php?roll_no=3 I would like to echo Xaz. Thanks for the help.

19th Oct 2016, 11:06 AM
Divyanshu Aggarwal
Divyanshu Aggarwal - avatar
1 Réponse
0
try this - echo $details[$_GET['roll_no']-1]['name']
19th Oct 2016, 11:46 AM
santosh ojha
santosh ojha - avatar