title: "set value in php"
body: <p>This is my part of my code:</p>
  
  <pre><code>&lt;?php
  require_once 'lib/shopify.php';
  //require_once 'csv.php';
  $t  = "bac2486aa2b31aa5aed1fdd62e77a4ae";
  $sc = new ShopifyClient("mine-329.myshopify.com/", $t, API_KEY, SECRET);
  if (!isset($t)) {
      if (!isset($_GET['signature'])) {
          $url = $sc-&gt;getAuthorizeUrl("read_orders");
          header('Location: ' . $url);
      }
      if (isset($_GET['code'])) {
          $accTok = $sc-&gt;getAccessToken($_GET['code']);
          echo "token = " . $accTok;
          exit;
          $orders = $sc-&gt;call('GET', 'admin/orders.json', array(
              'published_status' =&gt; 'published'
          ));
          foreach ($orders as $order) {
              echo $order['id'];
              echo $order['email'];
          }
      }
  }
  if (isset($t)) {
      $orders               = $sc-&gt;call('GET', 'admin/orders.json', array(
          'published_status' =&gt; 'published'
      ));
      $myarray              = array();
      $list[]               = array(
          'Name',
          'Email',
          'Financial status',
          'Paid at',
          'Fullfillment Status',
          'Fullfilled at',
          'Accepts Marketing',
          'Currency',
          'Subtotal',
          'Shipping',
          'Taxes',
          'Total',
          'Discount code',
          'Discount Amount',
          'Shipping Method',
          'created at',
          'Lineitem quantity',
          'Lineitem name',
          'Lineitem price',
          'compare at price',
          'Lineitem sku',
          'Lineitem requires shipping',
          'Lineitem taxable',
          'Lineitem fulfillment status',
          'Billing Name',
          'Billing Street',
          'Billing Address1',
          'Billing Address2',
          'Billing Company',
          'Billing City',
          'Billing Zip',
          'Billing Province',
          'Billing Country',
          'Billing Phone',
          'Shipping Name',
          'Shipping Street',
          'Shipping Address1',
          'Shipping Address2',
          'Shipping Company',
          'Shipping City',
          'Shipping Zip',
          'Shipping Province',
          'Shipping Country',
          'Shipping Phone',
          'Notes',
          'Note_attributes',
          'VAT',
          'Cancelled at',
          'Payment Method',
          'Payment Reference',
          'Refund',
          'Vendor',
          'Id',
          'Tags'
      );
      $list                 = array_filter($list);
      $empty_note_attribute = "";
      if (empty($order['note_attributes'])) {
          $empty_note_attribute = "";
      } else {
          $empty_note_attribute = $order['note_attributes'];
      }
      $empty_discount_codes = "";
      if (empty($order['discount_codes'])) {
          $empty_discount_codes = "";
      } else {
          $empty_discount_codes = $order['discount_codes'];
      }
  
  
  
  $countryCodes = array('United States' =&gt; 'US','India'=&gt;'IN');
  
      foreach ($orders as $order) {
  
          $orders_lineitem = $order['line_items'];
          $lineitemcount   = 0;
          foreach ($orders_lineitem as $lineitem) {
              /*
              Fulfillment Status
              */
              $fulfill_status = "";
              if (empty($order['fulfillment_status'])) {
                  $fulfill_status = "pending";
              } else {
                  $fulfill_status = $order['fulfillment_status'];
              }
              /*
              Lineitem Fulfillment Status
              */
              $fulfillment_status = '';
              if (empty($order['fulfillments'][0]['created_at'])) {
                  $fulfillment_status = "pending";
              } else {
                  $fulfillment_status = $order['line_items'][0]['fulfillment_status'];
              }
              $variants          = "";
              $variants          = $sc-&gt;call('GET', "admin/variants/" . $lineitem['variant_id'] . ".json", array(
                  'published_status' =&gt; 'published'
              ));
              $requires_shipping = "false";
              if ($lineitem['requires_shipping']) {
                  $requires_shipping = "true";
              }
              $lineitem_taxable = "false";
              if ($lineitem['taxable']) {
                  $lineitem_taxable = "true";
              }
              //** Accepts Marketting **
  
              $accepts_marketting = "no";
              if ($order['buyer_accepts_marketing']) {
                  $accepts_marketting = "yes";
              }
              $shipping = '';
              if (count($order['shipping_lines']) &gt; 0) {
                  $shipping = $order['shipping_lines'][0]['price'];
              }
              /* 
              Fulfilled at
              */
              $created_at = '';
              if (count($order['fulfillments']) &gt; 0) {
                  $created_at = $order['fulfillments'][0]['created_at'];
              }
              /*  
              Refunded Amount 
              */
              $refund_price = '';
              if (count($order['refunds']) &gt; 0) {
                  foreach ($order['refunds'] as $refund) {
                      $refund_price += $refund['transactions'][0]['receipt']['paid_amount'];
                  }
              }
              if ('pending' == $fulfill_status || 'partial' == $fulfill_status) {
                  $created_at = '';
              }
  
              if ($lineitemcount == 0) {
                  array_push($list, array(
                      $order['name'],
                      $order['email'],
                      $order['financial_status'],
                      (($order['financial_status'] != 'partially_refunded') &amp;&amp; ($order['financial_status'] != 'refunded') &amp;&amp; ($order['financial_status'] != 'authorized')? $order['created_at'] : null),
                      $fulfill_status,
                      $created_at,
                      $accepts_marketting,
                      $order['currency'],
                      $order['subtotal_price'],
                      (($shipping &gt; 0) ? $shipping : 0),
                      $order['total_tax'],
                      $order['total_price'],
                      $empty_discount_codes,
                      $order['total_discounts'],
                      (($shipping &gt; 0) ? $order['shipping_lines'][0]['code'] : null),
                      $order['created_at'],
                      $lineitem['quantity'],
                      $lineitem['name'],
                      $lineitem['price'],
                      $variants['compare_at_price'],
                      $lineitem['sku'],
                      $requires_shipping,
                      $lineitem_taxable,
                      $fulfillment_status,
                      $order['billing_address']['name'],
                      $order['billing_address']['address1'],
                      $order['billing_address']['address1'],
                      $order['billing_address']['address2'],
                      $order['billing_address']['company'],
                      $order['billing_address']['city'],
                      $order['billing_address']['zip'],
                      $order['billing_address']['province'],
                      $order['billing_address']['country'],
                $order['billing_address']['phone'],
                      (($shipping &gt; 0) ? $order['shipping_address']['name'] : null),
                      (($shipping &gt; 0) ? $order['shipping_address']['address1'] : null),
                      (($shipping &gt; 0) ? $order['shipping_address']['address1'] : null),
                      (($shipping &gt; 0) ? $order['shipping_address']['address2'] : null),
                      (($shipping &gt; 0) ? $order['shipping_address']['company'] : null),
                      (($shipping &gt; 0) ? $order['shipping_address']['city'] : null),
                      (($shipping &gt; 0) ? $order['shipping_address']['zip'] : null),
                      (($shipping &gt; 0) ? $order['shipping_address']['province'] : null),
                      (($shipping &gt; 0) ? $order['shipping_address']['country'] : null),
                      (($shipping &gt; 0) ? $order['shipping_address']['phone'] : null),
                      $order['note'],
                      $empty_note_attribute,
                      (($order['line_items'][0]['tax_lines'][0]['price'] != '0') ? $order['total_tax'] : null),
                      $order['cancelled_at'],
                      $order['payment_details']['credit_card_company'],
                      $order['checkout_id'],
                      (($refund_price &gt; 0) ? $refund_price : 0),
                      $lineitem['vendor'],
                      $order['id'],
                      $order['tags']
                  ));
              } else {
                  array_push($list, array(
                      $order['name'],
                      $order['email'],
                      '',
                      '',
                      '',
                      '',
                      '',
                      '',
                      '',
                      '',
                      '',
                      '',
                      $empty_discount_codes,
                      '',
                      '',
                      $order['created_at'],
                      $lineitem['quantity'],
                      $lineitem['name'],
                      $lineitem['price'],
                      $variants['compare_at_price'],
                      $lineitem['sku'],
                      $requires_shipping,
                      $lineitem_taxable,
                      $order['line_items'][0]['fulfillment_status'],
                      '',
                      '',
                      '',
                      '',
                      '',
                      '',
                      '',
                      '',
                      '',
                      '',
                      '',
                      '',
                      '',
                      '',
                      '',
                      '',
                      '',
                      '',
                      '',
                      '',
                      '',
                      '',
                      '',
                      '',
                      '',
                      '',
                      '',
                      $lineitem['vendor'],
                      '',
                      $order['tags']
                  ));
              }
              $lineitemcount++;
          }
      }
      $order  = $_GET;
      $list[] = array_to_csv_download($myarray, // this array is going to be the second row
          "numbers.csv");
      $list   = array_filter($list);
      array_to_csv_download($list);
      header("Content-type: text/csv");
      header("Content-Disposition: attachment; filename=file.csv");
      header("Pragma: no-cache");
      header("Expires: 0");
  }
  function array_to_csv_download($list)
  {
      $output = fopen("php://output", "w");
      foreach ($list as $row) {
          fputcsv($output, $row);
          //print_r($row); die;
      }
      fclose($output);
  }
  ?&gt;
  </code></pre>
  
  <p>And this is my output:</p>
  
  <p><a href="http://imgur.com/bmEtbxB" rel="nofollow">http://imgur.com/bmEtbxB</a> </p>
  
  <p>Now I got value of country like India or united states..etc.(i.e., corresponding country name). Now how to set IN or US. (I.E., if India means it will print IN and likewise)</p>
  
  <p>Can anybody help me?</p>
  
  <p>Thanks in advance!.</p>