Ember_Celica

Json Processing

Nov 12th, 2016
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.83 KB | None | 0 0
  1. <?php
  2. function objectToArray($data)
  3.   {
  4.       if (is_object($data)) {
  5.           // Gets the properties of the given object
  6.           // with get_object_vars function
  7.           $d = get_object_vars($data);
  8.       }
  9.  
  10.       if (is_array($data)) {
  11.           /*
  12.           * Return array converted to object
  13.           * Using __FUNCTION__ (Magic constant)
  14.           * for recursive call
  15.           */
  16.           return array_map(__FUNCTION__, $data);
  17.       } else {
  18.           // Return array
  19.           return $data;
  20.       }
  21.   }
  22.      
  23. $url = curl_init("http://cards.renmx.com/json.php");
  24. curl_setopt($url, CURLOPT_HTTPHEADER, array(//cookie));
  25. $urlReturn = curl_exec($url);
  26. //$urlDecode = json_decode($urlReturn);
  27. //$jsonArray = objectToArray($urlDecode);
  28. //print_r($jsonArray);
  29. //print("<br /> \n \n");
  30. //var_dump($jsonArray);
  31.  
  32. ?>
Advertisement
Add Comment
Please, Sign In to add comment