Guest User

Untitled

a guest
Aug 21st, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. {
  2. "points": [
  3. [52.93839800000001,-1.1425212999999999],
  4. [52.93839800000001,-1.1425212999999999],
  5. [52.93839800000001,-1.1425212999999999],
  6. [52.93839800000001,-1.1425212999999999],
  7. [52.93839800000001,-1.1425212999999999]
  8. ]
  9. }
  10.  
  11. $sql = "SELECT latlong from requests";
  12. $result = $con->query($sql);
  13.  
  14. if ($result->num_rows > 0) {
  15. // output data of each row
  16. while($row = $result->fetch_assoc()) {
  17. echo $row['latlong'] . "<br>";
  18. }
  19. } else {
  20. echo "0 results";
  21. }
  22. $con->close();
  23.  
  24. $str = '{
  25. "points": [
  26. [52.93839800000001,-1.1425212999999999],
  27. [52.93839800000001,-1.1425212999999999],
  28. [52.93839800000001,-1.1425212999999999],
  29. [52.93839800000001,-1.1425212999999999],
  30. [52.93839800000001,-1.1425212999999999]
  31. ]
  32. }';
  33. $arr = json_decode($str,true); // decode to array
  34.  
  35. foreach($arr["points"] as $row){ // loop points array
  36. echo "lat " . $row[0] . "n";
  37. echo "lon " . $row[1] . "nn";
  38. }
  39.  
  40. lat 52.938398
  41. lon -1.1425213
  42.  
  43. lat 52.938398
  44. lon -1.1425213
  45.  
  46. lat 52.938398
  47. lon -1.1425213
  48.  
  49. lat 52.938398
  50. lon -1.1425213
  51.  
  52. lat 52.938398
  53. lon -1.1425213
Add Comment
Please, Sign In to add comment