I have an array in my PHP code which looks like this:
Array
(
[1] => Array
(
[subject_id] => 1
[subject] => Math
[default_selection] => 1
)
[2] => Array
(
[subject_id] => 2
[subject] => Physics
[default_selection] => 0
)
[3] => Array
(
[subject_id] => 3
[subject] => Chemistry
[default_selection] => 0
)
[4] => Array
(
[subject_id] => 4
[subject] => Biology
[default_selection] => 0
)
[5] => Array
(
[subject_id] => 5
[subject] => Statistics
[default_selection] => 0
)
)
I would like to get the value of [subject] where [subject_id]= 2. Is there any direct/shortcut to do this in PHP or I need to run a foreach loop ?