d1ch0t0my
d1ch0t0my

Reputation: 443

PHP JSON array if equals value then echo

I'm trying to get a specific link for each of my videos from the Vimeo API. I can loop through the results and echo them in a foreach but when I try to access a specific value it still out puts all the results:

    // Make Request
    $response = $lib->request('/videos/'.$vurl.'?fields=files', [ ], 'GET');

    // Get Response
    $links = $response['body']['files'];

    foreach ($links as $key => $value) {

        if ($value['width'] = '1920') {

            echo $value['link_secure'];

        } else {

            echo 'no match';

        }
    }

How do I access just the result where the $value equals '1920'?

Upvotes: 0

Views: 73

Answers (1)

Ashish Patel
Ashish Patel

Reputation: 633

use == instead of = here.

 if ($value['width'] == 1920) {

        echo $value['link_secure'];

    } else {

        echo 'no match';

    }

Upvotes: 2

Related Questions