title: Converting object to array in laravel
body: <p>i queried a DB like this which got me an array:</p>
  
  <pre><code>foreach($oid as $orderid) {
      $orderdetailData[] = DB::table('order_details')
          -&gt;join('orders', 'order_details.oid', '=', 'orders.oid')
          -&gt;select('order_details.oid', 'orders.ostatus')
          -&gt;where('order_details.oid', $orderid)-&gt;get();
      }
  
      $data = array_flatten($orderdetailData);
      return $data;
  </code></pre>
  
  <p>This is the array i get</p>
  
  <pre><code>array (size=2)
    0 =&gt; 
      object(stdClass)[174]
        public 'oid' =&gt; int 1
        public 'ostatus' =&gt; string 'Placed' (length=6)
    1 =&gt; 
      object(stdClass)[158]
        public 'oid' =&gt; int 2
        public 'ostatus' =&gt; string 'Placed' (length=6)
  </code></pre>
  
  <p>I am trying to get this array in the form</p>
  
  <pre><code>array (size=2)
    0 =&gt; 
      array (size=2)
        public 'oid' =&gt; int 1
        public 'ostatus' =&gt; string 'Placed' (length=6)
    1 =&gt; 
      array (size=2)
        public 'oid' =&gt; int 2
        public 'ostatus' =&gt; string 'Placed' (length=6)
  </code></pre>
  
  <p>I tried doing this: </p>
  
  <pre><code>foreach($orderdetailData as $key =&gt; $value){
      $data[] = array_flatten($orderdetailData[$key]);
  }
  </code></pre>
  
  <p>But doing this gets me an array in this form: </p>
  
  <pre><code>array (size=2)
    0 =&gt; 
      array (size=1)
        0 =&gt; 
          object(stdClass)[174]
            public 'oid' =&gt; int 1
            public 'ostatus' =&gt; string 'Placed' (length=6)
    1 =&gt; 
      array (size=1)
        0 =&gt; 
          object(stdClass)[158]
            public 'oid' =&gt; int 2
            public 'ostatus' =&gt; string 'Placed' (length=6)
  </code></pre>
  
  <p>Which is not i what i am looking for. Can someone tell me what would be an easy way to do this ? Thanks</p>