title: Return php variable from CURL post
body: <p>I working with the TradeGecko API and need to create a new customer via a curl post request. It creates the post successfully and returns a json response (below). How do I retrieve the <code>id</code> from the JSON response as a PHP variable?</p>
  
  <pre><code>function createCompany($client, $customerID, $customer_first_name, $customer_last_name, $customer_company_name,
                         $customer_company_email, $customer_company_phone)
  {
  
      //API Url
      $url = 'https://api.tradegecko.com/companies';
  
      //Initiate cURL.
      $ch = curl_init($url);
  
      $jsonData =
          array(
              'assignee_id' =&gt; NULL,
              'default_ledger_account_id' =&gt; null,
              'default_payment_term_id' =&gt; null,
              'default_stock_location_id' =&gt; null,
              'default_tax_type_id' =&gt; null,
              'default_ledger_account_id' =&gt; null,
              'default_payment_term_id' =&gt; null,
              'default_stock_location_id' =&gt; null,
              'default_tax_type_id' =&gt; null,
              'company_code' =&gt; $customerID,
              'company_type' =&gt; "consumer",
              'default_discount_rate' =&gt; null,
              'default_price_list_id' =&gt; null,
              'default_tax_rate' =&gt; null,
              'default_document_theme_id' =&gt; null,
              'description' =&gt; "$customer_first_name $customer_last_name - synced for OceanAngler e-shop",
              'email' =&gt; "$customer_company_email",
              'fax' =&gt; null,
              'name' =&gt; "$customer_first_name $customer_last_name",
              'phone_number' =&gt; "$customer_company_phone",
              'status' =&gt; 'active',
              'tax_number' =&gt; null,
              'website' =&gt; null, // double check this in orders
              'default_price_type_id' =&gt; null
  
  
          );
  
      //Encode the array into JSON.
      $jsonDataEncoded = json_encode($jsonData);
  
      $authorization = "Authorization: Bearer [token goes here]";
  
  
      //Tell cURL that we want to send a POST request.
      curl_setopt($ch, CURLOPT_POST, 1);
  
      //Attach our encoded JSON string to the POST fields.
      curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonDataEncoded);
  
      //Set the content type to application/json
      curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json', $authorization));
  
      //Execute the request
      $result = curl_exec($ch);
  
  }
  </code></pre>
  
  <p>It returns an output like this.</p>
  
  <pre><code>{  
    "company":{  
    "id":12697094,
    "created_at":"2017-03-01T01:28:28.679Z",
    "updated_at":"2017-03-01T01:28:28.679Z",
    "assignee_id":null,
    "default_ledger_account_id":null,
    "default_payment_term_id":null,
    "default_payment_method_id":null,
    "default_stock_location_id":null,
    "default_tax_type_id":null,
    "company_code":"12",
    "company_type":"consumer",
    "default_discount_rate":null,
    "default_price_list_id":null,
    "default_tax_rate":null,
    "default_document_theme_id":null,
    "description":"Aniken Skywalker - synced from e-shop",
    "email":"aniken@gmail.com",
    "fax":null,
    "name":"Aniken Skywalker",
    "phone_number":"0229329201",
    "status":"active",
    "tax_number":null,
    "website":null,
    "tags":null,
    "address_ids":[  
  
    ],
    "contact_ids":[  
  
    ],
    "note_ids":[  
  
    ],
    "default_price_type_id":null
    }
  }
  </code></pre>
  
  <p>How do I return 'id' as a PHP variable? </p>