Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angellist api not returning data in foreach loop

Tags:

php

I grabbed the 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 on my screen. So everything is fine until the next step.

When i use a foreach loop and i print out $list, nothing shows. What am i missing?

        foreach($angellist as $list):

            pr($list);

            endforeach; 

If you need more information, I am happy to oblige.

like image 934
user2314339 Avatar asked May 21 '26 06:05

user2314339


1 Answers

Decode it using JSON to convert it into array and use it in foreach loop.Use the code below

<?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

like image 115
Utkarsh Dixit Avatar answered May 24 '26 10:05

Utkarsh Dixit



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!