Answer the question
In order to leave comments, you need to log in
How to store the result from an external reference into a variable?
There is an external resource that issues an array using a link
https://api.deezer.com/search?q=LUCKY%20LUKE%20HYP...
It is
required to save the contents of "cover_medium" to a variable
Please tell me how to implement this.
Answer the question
In order to leave comments, you need to log in
I do not like this way, but the essence will be clear:
<?php
$payload = \file_get_contents('https://api.deezer.com/search?q=LUCKY%20LUKE%20HYPNOTIZING');
$payload = \json_decode($payload, true, 512, JSON_THROW_ON_ERROR);
$media = $payload['data'][0]['album']['cover_medium'] ?? 'media_not_found.jpg';
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question