Angellist api not returning data in foreach loop

First of all, best wishes to all of you.

I'm new to API development, so naked with me :)

I took data with the following code:

$angellist = file_get_contents('https://api.angel.co/1/startups/6702/jobs');

      

When I print $ angellist, I get the data returned to the screen. So, everything will be fine until the next step.

When I use a foreach loop and I print out $ list nothing is displayed. What am I missing?

        foreach($angellist as $list):

            pr($list);

            endforeach; 

      

If you need more information, I will gladly commit.

+3


source to share


1 answer


Decode it with JSON to convert it to an array and use it in your foreach loop. Use below code

<?php
$url = file_get_contents('https://api.angel.co/1/startups/6702/jobs');
$angellist = json_decode($url,true);
 foreach($angellist as $list):

            pr($list);

            endforeach; 

      



Hope this helps you

+1


source







All Articles