· 7 years ago · Jan 06, 2018, 09:26 AM
1$recommendations = array();
2 foreach ($query_top_checkins->result() as $row) {
3 $checkin = $row;
4 echo "<strong>" . $checkin->place_name . "</strong><br/>";
5 // calculate distance from available apartments
6 foreach ($query->result() as $row_apt) {
7 $apartment = $row_apt;
8 //echo "apartment lat/lng: " . $apartment->latitude . "/" . $apartment->longitude . " || checkin lat/lng: " . $checkin->latitude . "/" . $checkin->longitude . "<br/>";
9 echo "distance of apt-".$apartment->apt_id."-(" . $apartment->address . ") to checkin location(". $checkin->place_name ."): " . getDistance($checkin->latitude, $checkin->longitude, $apartment->latitude, $apartment->longitude, true) . "<br/>";
10 $recommendations[$apartment->apt_id] = getDistance($checkin->latitude, $checkin->longitude, $apartment->latitude, $apartment->longitude, true);
11 }
12 }
13
14## var_dump of $apartment
15object(stdClass)#17 (8) { ["company"]=> string(18) "Bankier Apartments" ["apt_id"]=> string(1) "5" ["address"]=> string(12) "408 E. Green" ["bedrooms"]=> string(1) "1" ["bathrooms"]=> string(3) "1.0" ["price"]=> string(6) "790.00" ["longitude"]=> string(10) "-88.232471" ["latitude"]=> string(9) "40.110290" } distance of apt-13-(1010 W Stoughton) to checkin location(Wohlers%20Hall): 0.952944831599
16object(stdClass)#18 (8) { ["company"]=> string(26) "Campus Property Management" ["apt_id"]=> string(2) "13" ["address"]=> string(16) "1010 W Stoughton" ["bedrooms"]=> string(1) "2" ["bathrooms"]=> string(3) "1.0" ["price"]=> string(6) "979.00" ["longitude"]=> string(10) "-88.221738" ["latitude"]=> string(9) "40.113658" } distance of apt-4-(310 Cedar Street Apt. #102) to checkin location(Wohlers%20Hall): 1.73950598021
17object(stdClass)#19 (8) { ["company"]=> string(13) "CU-Apartments" ["apt_id"]=> string(1) "4" ["address"]=> string(26) "310 Cedar Street Apt. #102" ["bedrooms"]=> string(1) "2" ["bathrooms"]=> string(3) "1.0" ["price"]=> string(6) "850.00" ["longitude"]=> string(10) "-88.246785" ["latitude"]=> string(9) "40.099015" } distance of apt-2-(705 E. Colorado Ave) to checkin location(Wohlers%20Hall): 3.10359727983
18object(stdClass)#20 (8) { ["company"]=> string(25) "Gillespie Management, Inc" ["apt_id"]=> string(1) "2" ["address"]=> string(19) "705 E. Colorado Ave" ["bedrooms"]=> string(1) "2" ["bathrooms"]=> string(3) "1.5" ["price"]=> string(6) "905.00" ["longitude"]=> string(10) "-88.197513" ["latitude"]=> string(9) "40.094554" } distance of apt-17-(305 E. John) to checkin location(Wohlers%20Hall): 0.919753451752
19object(stdClass)#21 (8) { ["company"]=> string(19) "Green Street Realty" ["apt_id"]=> string(2) "17" ["address"]=> string(11) "305 E. John" ["bedrooms"]=> string(1) "2" ["bathrooms"]=> string(3) "1.0" ["price"]=> string(7) "1200.00" ["longitude"]=> string(10) "-88.228991" ["latitude"]=> string(9) "40.115906" } distance of apt-9-(1002 W Springfield Ave) to checkin location(Wohlers%20Hall): 0.959178571315
20object(stdClass)#22 (8) { ["company"]=> string(19) "Ramshaw Real Estate" ["apt_id"]=> string(1) "9" ["address"]=> string(22) "1002 W Springfield Ave" ["bedrooms"]=> string(1) "2" ["bathrooms"]=> string(3) "1.0" ["price"]=> string(6) "725.00" ["longitude"]=> string(10) "-88.220901" ["latitude"]=> string(9) "40.113018" } distance of apt-12-(101 E. Green) to checkin location(Wohlers%20Hall): 0.771959637916
21object(stdClass)#23 (8) { ["company"]=> string(13) "Roland Realty" ["apt_id"]=> string(2) "12" ["address"]=> string(12) "101 E. Green" ["bedrooms"]=> string(1) "2" ["bathrooms"]=> string(3) "1.0" ["price"]=> string(6) "950.00" ["longitude"]=> string(10) "-88.238352" ["latitude"]=> string(9) "40.109834" }
22
23## var_dump of keys
24it's hard to var_dump because it's in a loop, here's one
25
26object(stdClass)#16 (11) { ["id"]=> string(2) "13" ["foursquare_user_id"]=> string(5) "13911" ["oauth_token"]=> string(6) "xxyyzz" ["checkin_count"]=> string(1) "9" ["place_name"]=> string(14) "Wohlers%20Hall" ["address"]=> string(29) "1206%20South%20Sixth%20Street" ["city"]=> string(9) "Champaign" ["state"]=> string(2) "IL" ["zipcode"]=> string(5) "61820" ["latitude"]=> string(9) "40.107654" ["longitude"]=> string(10) "-88.229734" }