taking the values received from json_decode

Asked

Viewed 131 times

1

So I have this code

$result = json_decode($output, true);

var_dump($result);

it is generating the following.

    array(3){
  [
    "status"
  ]=>string(9)"completed"[
    "flights"
  ]=>array(2){
    [
      "outbound"
    ]=>array(9){
      [
        "E_0830_1140_2176"
      ]=>array(6){
        [
          "Flight"
        ]=>array(14){
          [
            "class"
          ]=>string(1)"E"[
            "airline"
          ]=>string(2)"G3"[
            "number"
          ]=>string(4)"2176"[
            ---------------------->**"from"**
          ]=>string(3)"GIG"[
            "to"
          ]=>string(3)"FOR"[
            "departure"
          ]=>int(1523532600)[
            "departure_date"
          ]=>string(10)"2018-04-12"[
            "departure_time"
          ]=>string(5)"08:30"[
            "arrival"
          ]=>int(1523544000)[
            "arrival_date"
          ]=>string(10)"2018-04-12"[
            "arrival_time"
          ]=>string(5)"11:40"[
            "flight_time"
          ]=>int(11400)[
            "str_flight_time"
          ]=>string(5)"3h10m"[
            "national"
          ]=>bool(true)
        }

I would like to take the result of "from" by EX and play it on "echo" and bring it separately to be able to style the same.

  • you access json by php yourself?

  • yes, I call json from PHP, then use Decode to return the values searched in php, $result = json_decode($output, true);

  • get the result and it generates a url, then get the results of this url and play on my page... code that I use to get the url and play the result. 

 $curl = curl_init();
 $url = $cap_url;
 curl_setopt($curl, CURLOPT_URL, $cap_url);
 curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
 curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
 $output = curl_exec($curl);
 curl_close($curl);

  • Here is the solution => https://answall.com/questions/4410/received-data

  • 1

    Possible duplicate of Receive external JSON data from PHP

  • then it would be $items = $result['from']; foreach ( $items as $e ) { echo $e['in-pra']." <br>"; }

  • error Invalid argument supplied for foreach().

  • Can you put an example of the original array? I can help you if you have an example of the original json.

Show 3 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.