I have an array that looks like this :
Array
(
[2019] => Array
(
[2019] => Array
(
[year] => 2019
[amount] => 3269.93
[type] => charge
)
)
[2018] => Array
(
[2018] => Array
(
[year] => 2018
[amount] => 219.25
[type] => payout
)
)
[2017] => Array
(
[2017] => Array
(
[year] => 2017
[amount] => 214.06
[type] => charge
)
)
)
I tried with array_search() but I don't think it works to accomplish what I want.
According to the manual, array_search() is used to search for a particular value in an array, and if the value is found then it returns its corresponding key. This takes in account that we know what the value we look for is and that we want to return the key. I want to do it in reverse. I know the key but I do not know the value and I want to return the value not the key.
I'm trying to do something similar to MYSQL "select amount where year='2017'"
but with an array.
How can I accomplish this? Any idea?