[GH-ISSUE #201] Recover images in search #138

Closed
opened 2026-02-27 19:26:15 +03:00 by kerem · 5 comments
Owner

Originally created by @DarKl4ne on GitHub (Aug 30, 2020).
Original GitHub issue: https://github.com/jwilsson/spotify-web-api-php/issues/201

Hello

I wanted to know how we can get the address of the image when we do an album search. I tried but still have an array error. So i can't do it

thank you for your help

Originally created by @DarKl4ne on GitHub (Aug 30, 2020). Original GitHub issue: https://github.com/jwilsson/spotify-web-api-php/issues/201 Hello I wanted to know how we can get the address of the image when we do an album search. I tried but still have an array error. So i can't do it thank you for your help
kerem 2026-02-27 19:26:15 +03:00
  • closed this issue
  • added the
    question
    label
Author
Owner

@adamazad commented on GitHub (Aug 30, 2020):

Can you post the code snippet for it?

<!-- gh-comment-id:683444823 --> @adamazad commented on GitHub (Aug 30, 2020): Can you post the code snippet for it?
Author
Owner

@DarKl4ne commented on GitHub (Aug 30, 2020):

Here is the display for research

foreach ($results->albums->items as $album) {
    //echo 'Titre: '.$album->images, '<br>';
    echo 'Titre: '.$album->name, '<br>';
    echo 'Date: '.$album->release_date, '<br>';
    echo 'Nombre de piste: '.$album->total_tracks, '<br>';
	echo $album['images']['1']->url;
}

Dans l'adresse api les images sont déjà dans array qui est items

[items] => Array
                (
**"Information that I collect"**
[images] => Array
                                (
                                    [0] => stdClass Object
                                        (
                                            [height] => 640
                                            [url] => https://i.scdn.co/image/ab67616d0000b273614c5f63afef27e4dfa9f596
                                            [width] => 640
                                        )

                                    [1] => stdClass Object
                                        (
                                            [height] => 300
                                            [url] => https://i.scdn.co/image/ab67616d00001e02614c5f63afef27e4dfa9f596
                                            [width] => 300
                                        )

                                    [2] => stdClass Object
                                        (
                                            [height] => 64
                                            [url] => https://i.scdn.co/image/ab67616d00004851614c5f63afef27e4dfa9f596
                                            [width] => 64
                                        )

                                )

So I would like to know how to retrieve information from an array which is already in an array

thank you

<!-- gh-comment-id:683446556 --> @DarKl4ne commented on GitHub (Aug 30, 2020): Here is the display for research ``` foreach ($results->albums->items as $album) { //echo 'Titre: '.$album->images, '<br>'; echo 'Titre: '.$album->name, '<br>'; echo 'Date: '.$album->release_date, '<br>'; echo 'Nombre de piste: '.$album->total_tracks, '<br>'; echo $album['images']['1']->url; } ``` Dans l'adresse api les images sont déjà dans array qui est items ``` [items] => Array ( **"Information that I collect"** [images] => Array ( [0] => stdClass Object ( [height] => 640 [url] => https://i.scdn.co/image/ab67616d0000b273614c5f63afef27e4dfa9f596 [width] => 640 ) [1] => stdClass Object ( [height] => 300 [url] => https://i.scdn.co/image/ab67616d00001e02614c5f63afef27e4dfa9f596 [width] => 300 ) [2] => stdClass Object ( [height] => 64 [url] => https://i.scdn.co/image/ab67616d00004851614c5f63afef27e4dfa9f596 [width] => 64 ) ) ``` So I would like to know how to retrieve information from an array which is already in an array thank you
Author
Owner

@adamazad commented on GitHub (Aug 30, 2020):

$album is a stdClass, so try:

$album->images['1']->url;
<!-- gh-comment-id:683447131 --> @adamazad commented on GitHub (Aug 30, 2020): `$album` is a `stdClass`, so try: ``` $album->images['1']->url; ```
Author
Owner

@DarKl4ne commented on GitHub (Aug 30, 2020):

Thank you very much it works

I was not far away I had done like this echo $album['images']['1']->url;

<!-- gh-comment-id:683449064 --> @DarKl4ne commented on GitHub (Aug 30, 2020): Thank you very much it works I was not far away I had done like this echo $album['images']['1']->url;
Author
Owner

@jwilsson commented on GitHub (Aug 30, 2020):

Glad you got it working!

And thanks @adamazad for helping out!

<!-- gh-comment-id:683464656 --> @jwilsson commented on GitHub (Aug 30, 2020): Glad you got it working! And thanks @adamazad for helping out!
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/spotify-web-api-php#138
No description provided.