Advertisement
Daniel_HBK

Untitled

Mar 9th, 2023
822
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.65 KB | None | 0 0
  1. <?php
  2. // استدعاء البيانات من API أو مصدر آخر
  3. $data = file_get_contents("https://www.football-data.org/v2/competitions/PL/matches", false, stream_context_create([
  4.   "http" => [
  5.     "header" => "Accept: application/json\r\nX-Auth-Token: YOUR_API_KEY_HERE"
  6.   ]
  7. ]));
  8.  
  9. // تحويل البيانات من صيغة JSON إلى مصفوفة PHP
  10. $matches = json_decode($data, true)["matches"];
  11.  
  12. // عرض النتائج
  13. foreach ($matches as $match) {
  14.   echo $match["homeTeam"]["name"] . " " . $match["score"]["fullTime"]["homeTeam"] . " - " . $match["score"]["fullTime"]["awayTeam"] . " " . $match["awayTeam"]["name"] . "<br>";
  15. }
  16. ?>
  17.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement