search associative array by value

后端 未结 7 2068
感动是毒
感动是毒 2020-12-09 15:40

I\'m fetching some JSON from flickrs API. My problem is that the exif data is in different order depending on the camera. So I can\'t hard-code an array number to get, for i

相关标签:
7条回答
  • 2020-12-09 16:44

    To my knowledge there is no such function. There is array_search, but it doesn't quite do what you want.

    I think the easiest way would be to write a loop yourself.

    function search_exif($exif, $field)
    {
        foreach ($exif as $data)
        {
            if ($data['label'] == $field)
                return $data['raw']['_content'];
        }
    }
    
    $camera = search_exif($exif['photo']['exif'], 'model');
    
    0 讨论(0)
提交回复
热议问题