$open = (int) round($period->open->time / 100); $close = (int) round($period->close->time / 100); $difference = abs($close - $open); for ($k = $period->close->day; $k < $period->close->day + $difference; $k++) { $daily_hours[$period->close->day][$k] = 1; } } foreach ($daily_hours as $one_daily_hour_key => $one_daily_hour_value) { $temp_daily_hour = $daily_hours[$one_daily_hour_key]; $daily_hours[$one_daily_hour_key] = new DailyHours($one_daily_hour_value); } $place = new Place($name, $daily_hours, [new DailyHours([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 41, 37, 24, 3, 28, 0, 0, 0, 0, 0, 0, 0]), new DailyHours([0, 0, 0, 0, 0, 0, 0, 0, 28, 35, 42, 56, 78, 76, 54, 0, 0, 0, 0, 0, 0, 0, 0, 0]), new DailyHours([0, 0, 0, 0, 0, 0, 81, 83, 74, 63, 42, 28, 14, 17, 21, 31, 12, 15, 19, 23, 20, 0, 0, 0]), new DailyHours([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 41, 37, 24, 3, 28, 0, 0, 0, 0, 0, 0, 0]), new DailyHours([0, 0, 0, 0, 0, 0, 0, 0, 28, 35, 42, 56, 78, 76, 54, 0, 0, 0, 0, 0, 0, 0, 0, 0]), new DailyHours([0, 0, 0, 0, 0, 0, 81, 83, 74, 63, 42, 28, 14, 17, 21, 31, 12, 15, 19, 23, 20, 0, 0, 0]), new DailyHours([0, 0, 0, 0, 0, 0, 81, 83, 74, 63, 42, 28, 14, 17, 21, 31, 12, 15, 19, 23, 20, 0, 0, 0])], $rating); $places[$i] = $place; } $trip = new Trip(5, 9); $final_scores = $trip->order($places, $coordinates); // echo json_encode($final_scores); $google_maps = "https://www.google.com/maps/dir/39.9009656,-75.171894"; foreach ($coordinates as $coordinate) { $google_maps .= "/{$coordinate['latitude']},{$coordinate['longitude']}"; } // uber $uber = 0; // Get cURL resource $ch = curl_init(); // Set url curl_setopt($ch, CURLOPT_URL, 'https://api.uber.com/v1/estimates/time?start_latitude=39.905&start_longitude=-75.172'); // Set method curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET'); // Set options curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$address = $result->address_components[0]->long_name . " " . $result->address_components[1]->long_name . ", " . $result->address_components[2]->long_name . ", " . $result->address_components[3]->short_name . " " . $result->address_components[5]->short_name; $rating = $result->rating; if (!$rating) { $rating = 2.5; } $coordinate = ["latitude" => $result->geometry->location->lat, "longitude" => $result->geometry->location->lng]; $coordinates[$i] = $coordinate; $daily_hours = []; for ($j = 0; $j < 7; $j++) { $daily_hours[$j] = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; } $hours_results = $result->opening_hours; foreach ($hours_results->periods as $period) { $open = (int) round($period->open->time / 100); $close = (int) round($period->close->time / 100); $difference = abs($close - $open); for ($k = $period->close->day; $k < $period->close->day + $difference; $k++) { $daily_hours[$period->close->day][$k] = 1; } } foreach ($daily_hours as $one_daily_hour_key => $one_daily_hour_value) { $temp_daily_hour = $daily_hours[$one_daily_hour_key]; $daily_hours[$one_daily_hour_key] = new DailyHours($one_daily_hour_value); } $place = new Place($name, $daily_hours, [new DailyHours([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 41, 37, 24, 3, 28, 0, 0, 0, 0, 0, 0, 0]), new DailyHours([0, 0, 0, 0, 0, 0, 0, 0, 28, 35, 42, 56, 78, 76, 54, 0, 0, 0, 0, 0, 0, 0, 0, 0]), new DailyHours([0, 0, 0, 0, 0, 0, 81, 83, 74, 63, 42, 28, 14, 17, 21, 31, 12, 15, 19, 23, 20, 0, 0, 0]), new DailyHours([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 41, 37, 24, 3, 28, 0, 0, 0, 0, 0, 0, 0]), new DailyHours([0, 0, 0, 0, 0, 0, 0, 0, 28, 35, 42, 56, 78, 76, 54, 0, 0, 0, 0, 0, 0, 0, 0, 0]), new DailyHours([0, 0, 0, 0, 0, 0, 81, 83, 74, 63, 42, 28, 14, 17, 21, 31, 12, 15, 19, 23, 20, 0, 0, 0]), new DailyHours([0, 0, 0, 0, 0, 0, 81, 83, 74, 63, 42, 28, 14, 17, 21, 31, 12, 15, 19, 23, 20, 0, 0, 0])], $rating); $places[$i] = $place; } $trip = new Trip(5, 9); echo json_encode($trip->order($places, $coordinates)); // echo json_encode($places); // echo json_encode($coordinates);