PHP gets the specified data and displays it

December 31, 2018 21:50:47 one Reading (2487)
This article was last updated on December 31, 2018, and has not been updated for more than a year. If the article content or picture resources are invalid, please leave a message for feedback, and we will deal with it in a timely manner. Thank you!

 PHP gets the specified data and displays it

As shown in the figure, the above renderings show the acquired dynamic data and a display.

The code is as follows

  1. <? php
  2. error_reporting (E_ALL ^ E_NOTICE);
  3. function  aveCard(){
  4.      $url  =  '' ;   //Interface address
  5.      $data  =  array (
  6.                 'encode'=>'json'
  7.             );
  8.      $ch  = curl_init();
  9.     curl_setopt( $ch , CURLOPT_SSL_VERIFYPEER, false);
  10.     curl_setopt( $ch , CURLOPT_SSL_VERIFYHOST, 2);
  11.     curl_setopt( $ch , CURLOPT_URL,  $url );
  12.     curl_setopt( $ch , CURLOPT_CUSTOMREQUEST, 'POST');
  13.     curl_setopt( $ch , CURLOPT_RETURNTRANSFER, true);
  14.     curl_setopt( $ch , CURLOPT_TIMEOUT, 6);
  15.      $response  = curl_exec( $ch );
  16.      if ( $error =curl_error( $ch )){
  17.          return 'Damn it, it failed unexpectedly. F5 refresh and try again...';   //Failure display
  18.     }
  19.     curl_close( $ch );
  20.      $array_data  = json_decode( $response ,true);
  21.   //$array_data is the array retrieved. The specific data depends on the format returned by json, then the specified data is retrieved, placed in the place to be displayed, and I put it in the following table
  22.      echo  '<table border= "2"  style= "width: 50%;border-collapse: collapse;border-spacing: 0;" ><tr><th></th><th></th>
  23.     <tr><td ></td><td></td><td></td><td></td><td></td></tr>
  24.     <tr><td ></td><td></td><td></td><td></td><td></td></tr>
  25.     <tr><td></td><td></td><td></td><td></td><td></td></tr>
  26.     </tr></table>';
  27. }
  28. echo  aveCard();
  29. ?>

With the above code, it is clear to analyze the data~

 

End.


 

 weinxin
WeChat applet
Internet development, lifelong learners, welcome your attention!
 Willing

Comment

 unhappy  rainbow  look on  Diu Xiang  Good  funny  Flower core  Cry out  surprised  blink the eyes  Cool  Sad  Are you handsome?  gift  rose  anger  get angry  spray  Sleep?  Too happy  Little 999  ah
 sunlight  Spit out one's tongue  Grievance  smiling eyes  Star Moon  heart-broken  Eh  Insidious  doubt  that 's great  Snicker  Squint  shock  slightly  Yawn  Helpless to cry  Pick one's nose  Hum  expect  I don't care about you  love  candle

Current comments: 1 of which: visitor 1 blogger 0

    •  Splendid Garden Splendid Garden zero

      Thanks for sharing~