foreach loop in multidimensional array | SoloLearn: Learn to code for FREE!

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.

10/19/2016 11:06:02 AM

Divyanshu Aggarwal

1 Answer

New Answer

0

try this - echo $details[$_GET['roll_no']-1]['name']