Advertisement
Guest User

Untitled

a guest
Feb 24th, 2020
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. $urlArticles = file_get_contents('https://newsapi.org/v2/top-headlines?country=it&apiKey=24360f9344f84b25985408467c5df1e6');
  2. $urlArticlesArray = json_decode($urlArticles, true);
  3.  
  4. $articles = $urlArticlesArray['articles'];
  5. if($articles){
  6. for($i = 10; $i>=1; $i--) {
  7. $sites = $urlArticlesArray['articles'][$i];
  8. $title = $sites['title'];
  9. $foto = $sites['urlToImage'];
  10. $title = explode("- ", $title, 2);
  11. $title = $title[0];
  12. $title = str_replace(["-"], [""], $title);
  13. si(-1001461163403, "$foto", "<b>$title</b>");
  14. }
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement