Guest User

Untitled

a guest
Oct 22nd, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.49 KB | None | 0 0
  1. {"carrier":"R&L Carriers","charge":"99.13","service_days":"Wednesday Oct. 22, 2014"}
  2.  
  3. <?php
  4. //include ('mysql_connect.php');
  5.  
  6. $result = mysql_query('select * from quote where user_id = "'.$user_id.'" order by netCharge asc limit 1');
  7.  
  8. if (!$result) {
  9. die('Could not query:' . mysql_error());
  10. }
  11.  
  12. if (!$result) echo mysql_error();
  13.  
  14. $api_data = array();
  15. $api_count = '0';
  16. while ($row = mysql_fetch_array($result, MYSQLI_ASSOC)) {
  17.  
  18. $api_data[carrier] = $row['carrier'];
  19. $api_data[charge] = $row['netCharge'];
  20. $api_data[service_days] = $row['serviceDays'];
  21.  
  22. $api_count++;
  23.  
  24. }
  25.  
  26. $api_data = json_encode($api_data);
  27.  
  28. print_r($api_data);
  29.  
  30. ?>
  31.  
  32. <?php
  33.  
  34. $input = file_get_contents('api_request.php?dest_zip=66101&weight=200&class=50&ltl_shipment=X&Residential_Delivery=X');
  35. echo $input;
  36.  
  37. $obj = json_decode($input);
  38. var_dump($obj);
  39.  
  40. ?>
  41.  
  42. $array = json_decode($data, true);
  43.  
  44. {"carrier":"R&L Carriers","charge":"99.13","service_days":"Wednesday Oct. 22, 2014"}
  45.  
  46. <?php
  47.  
  48. $input = file_get_contents('example.json');
  49. echo $input;
  50. // {"carrier":"R&L Carriers","charge":"99.13","service_days":"Wednesday Oct. 22, 2014"}
  51.  
  52. $obj = json_decode($input);
  53. var_dump($obj);
  54. // object(stdClass)#1 (3) {
  55. // ["carrier"]=>
  56. // string(12) "R&L Carriers"
  57. // ["charge"]=>
  58. // string(5) "99.13"
  59. // ["service_days"]=>
  60. // string(23) "Wednesday Oct. 22, 2014"
  61. // }
  62.  
  63. $str = trim($str," ") ;
  64.  
  65. $str = trim($str,"n") ;
  66.  
  67. $str = stripslashes($str);
Add Comment
Please, Sign In to add comment