I'm trying to search the following array and return the array index that matches my search term.
I think I've confused myself even more as most of the answers I could find were about finding the key of a specified value and I need the opposite.
Basically I just want to return the array index that matches a stated value.
For example "youtube", which would return index[1] in this example.
array(2) {
[0]=> object(App\Models\Socials)#12 (5) {
["id"]=> string(1) "2"
["user_id"]=> string(1) "1"
["platform"]=> string(7) "twitter"
["platform_id"]=> string(12) "647356535365"
["platform_avatar"]=> string(30) "https://twitter.com/avatar.jpg"
}
[1]=> object(App\Models\Socials)#13 (5) {
["id"]=> string(1) "3"
["user_id"]=> string(1) "1"
["platform"]=> string(7) "youtube"
["platform_id"]=> string(10) "1132434321"
["platform_avatar"]=> string(30) "https://youtube.com/avatar.jpg"
}
}