Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, "http://api.travelpayouts.com/v1/prices/cheap?origin=ABA&destination=MOW&limit=1&token=91b5b4bed0355fa89cd2e1f783abf710");
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
- curl_setopt($ch, CURLOPT_HEADER, FALSE);
- curl_setopt($ch, CURLOPT_HTTPHEADER, array("X-Access-Token: 91b5b4bed0355fa89cd2e1f783abf710"));
- $response = curl_exec($ch);
- curl_close($ch);
- $products=json_decode($response,true);
- ?>
- <?php if(isset($products['data']) && is_array($products['data'])) {
- foreach ($products['data'] as $key => $data) {
- echo ($data[0]['price']);
- foreach ($data as $destination => $row) {
- }
- }
- }
- ?>
- <?php
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, "http://api.travelpayouts.com/v1/prices/cheap?origin=ABA&destination=AER&limit=1&token=91b5b4bed0355fa89cd2e1f783abf710");
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
- curl_setopt($ch, CURLOPT_HEADER, FALSE);
- curl_setopt($ch, CURLOPT_HTTPHEADER, array("X-Access-Token: 91b5b4bed0355fa89cd2e1f783abf710"));
- $response = curl_exec($ch);
- curl_close($ch);
- $products=json_decode($response,true);
- ?>
- <?php if(isset($products['data']) && is_array($products['data'])) {
- foreach ($products['data'] as $key => $data) {
- echo ($data[0]['price']);
- foreach ($data as $destination => $row) {
- }
- }
- }
- ?>
- <?php
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, "http://api.travelpayouts.com/v1/prices/cheap?origin=ABA&destination=HKT&limit=1&token=91b5b4bed0355fa89cd2e1f783abf710");
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
- curl_setopt($ch, CURLOPT_HEADER, FALSE);
- curl_setopt($ch, CURLOPT_HTTPHEADER, array("X-Access-Token: 91b5b4bed0355fa89cd2e1f783abf710"));
- $response = curl_exec($ch);
- curl_close($ch);
- $products=json_decode($response,true);
- ?>
- <?php if(isset($products['data']) && is_array($products['data'])) {
- foreach ($products['data'] as $key => $data) {
- echo ($data[0]['price']);
- foreach ($data as $destination => $row) {
- }
- }
- }
- ?>
- array(2) {
- [1]=>
- array(6) {
- ["price"]=>
- int(20400)
- ["airline"]=>
- string(2) "S7"
- ["flight_number"]=>
- int(3034)
- ["departure_at"]=>
- string(20) "2018-01-28T09:10:00Z"
- ["return_at"]=>
- string(20) "2018-02-03T16:20:00Z"
- ["expires_at"]=>
- string(20) "2017-12-17T05:55:26Z"
- }
- [2]=>
- array(6) {
- ["price"]=>
- int(25200)
- ["airline"]=>
- string(2) "S7"
- ["flight_number"]=>
- int(3034)
- ["departure_at"]=>
- string(20) "2018-01-28T09:10:00Z"
- ["return_at"]=>
- string(20) "2018-02-03T05:20:00Z"
- ["expires_at"]=>
- string(20) "2017-12-17T05:55:26Z"
- }
- }
- foreach ($products['data'] as $destination => $data) {
- foreach ($data as $dataKey => $dataValue) {
- echo $dataValue['price'].PHP_EOL;
- }
- }
- foreach ($products['data'] as $destination => $data) {
- $iNeedOnlyThisValue = array_shift($data); //После этого в дате не будет одного значения
- echo $iNeedOnlyThisValue['price'].PHP_EOL;
- }
Add Comment
Please, Sign In to add comment