I have an array of php objects that looks like
array(3) {
[0] object(stdClass)#153 (2) {
["key"] "a"
["val"] "2"
}
[1] object(stdClass)#154 (2) {
["key"] "b"
["val"] "2"
}
[2] object(stdClass)#155 (2) {
["key"] "c"
["val"] "5"
}
}
and I want to turn it into this
array(3) {
["a"] 2
["b"] 2
["c"] 5
}
I've tried some variations of foreach loops but can't quite figure it out because of each value of the original array being an object with two keys. How can I clean this up and get it into a straight array?