title: Fetching data from Oracle database and store into an array using PHP
body: <p>I'm trying to fetch data from database, date-with-time(timestamp) and values(number) , and storing into an array using php.</p>
  
  <p>here is my data in database as follows=</p>
  
  <pre><code>WD                                  DT
  
  25-FEB-15 12.14.00.000000 AM    15.739993
  
  25-FEB-15 12.23.00.000000 AM    13.698263   
  
  25-FEB-15 12.43.00.000000 AM    13.214383
  </code></pre>
  
  <p><strong>fetch.php</strong></p>
  
  <pre><code>&lt;?php
  include("md.php");
  $sql = "SELECT * from datatable";
  $result =oci_parse($conn, $sql);
  $r=oci_execute($result);
  $arr = array();
  $row=oci_num_rows($stid);
  $arr[0]=array('wd','dt');
  
  for($i=1; $i&lt;($row+1); $i++)
  {
      $arr[$i]= array(substr(oci_result($result, $i-1, "wd"),0,18),(float)oci_result($result,$i-1,"dt"));
      //$arr[$i]= array(substr(oci_result($result, $i-1, "wd"),0,18),(int)oci_result($result,$i-1,"dt"));
  
  }
  echo json_encode($arr);
  //print_r($arr);
  ?&gt;
  </code></pre>
  
  <p>$arr getting following output:
      [["WD"],["DT"]] </p>
  
  <p><strong>Q1.</strong>  Why am i not getting rest of data? where am i doing wrong?</p>
  
  <p>but if i use </p>
  
  <pre><code>while($row = oci_fetch_row($stid)){
  
      $arr[] = $row;
  }
  </code></pre>
  
  <p>if i use json_encode then =</p>
  
  <pre><code>[["25-FEB-15 12.14.00.000000 AM","15.739993"],["25-FEB-15 12.23.00.000000 AM","13.698263"],["25-FEB-15 12.43.00.000000 AM","13.214383"],....
  </code></pre>
  
  <p>if i use </p>
  
  <pre><code>while($row = oci_fetch_array($stid,OCI_ASSOC)){
  
    $arr[] = $row;
  }
  </code></pre>
  
  <p>if i use json_encode then =</p>
  
  <pre><code>[{"WD":"25-FEB-15 12.14.00.000000 AM","DT":"15.739993"},{"WD":"25-FEB-15 12.23.00.000000 AM","DT":"13.698263"},........]
  </code></pre>
  
  <p>I want the output as follows=</p>
  
  <pre><code>[["25-FEB-15 12.14.00 AM",15.739993],["25-FEB-15 12.23.00 AM",13.698263],["25-FEB-15 12.43.00 AM",13.214383],....]
  </code></pre>
  
  <p><strong>Q2.</strong>  How can i get it? 
  please help</p>