title: React Native Fetch sending array to PHP
body: <p>I am new to React-Native and PHP, I am trying to send an array from react-native to PHP on my server with code like this :</p>
  
  <pre><code>SaveData() {
  let { RoomNo } = this.state
  let q = [{"0":"BVR001","Stock_Code":"BVR001","1":0,"Qty":0},
           {"0":"BVR015","Stock_Code":"BVR015","1":0,"Qty":0},
           {"0":"BVR017","Stock_Code":"BVR017","1":0,"Qty":0}]
  
  let url = 'http://192.168.100.99/SaveMNB.php'
  
  fetch(url, {
    method : 'POST',
    headers : {
      'Accept' : 'application/json',
      'Content-Type' : 'application/json'
    },
    body : JSON.stringify({
      RoomNo : RoomNo,
      Orderan : q
    })
  })
    .then(res =&gt; res.json())
    .catch(err =&gt; Alert.alert('ERROR',err.toString(),
                  [{text: 'OK'}],{ cancelable: false }))
  }
  </code></pre>
  
  <p>while on the PHP side my code is as below :</p>
  
  <pre><code>&lt;?php
  include("dbconfig.php");
  
  $json = file_get_contents("php://input");
  
  $obj = json_decode($json,true);
  
  $RoomNo = $obj['RoomNo'];
  $OrderanX[] = $obj['Orderan'];
  
  $con = sqlsrv_connect($myServer,$MyDbR);
  if ( $con === false ) {
      die( print_r( sqlsrv_errors(), true));
  }
  
  foreach($OrderanX As $Order) {
      //HERE WILL BE LOOPING THE ARRAY AND PUT IT INTO DATABASE
  }
  
  echo json_encode('SUCCESS');
  
  ?&gt;
  </code></pre>
  
  <p>This will always return error because i am unable to pass the array from react-native to php.</p>
  
  <p>The Error is </p>
  
  <pre><code>SyntaxError: JSON Parse error: Unrecognized token '&lt;'
  </code></pre>
  
  <p>How to pass the array from react-native to php, thanks, helps are greatly appreciate.</p>
  
  <p>EDIT :</p>
  
  <p>However if i delete the foreach loop and change code to</p>
  
  <pre><code>echo json_encode($OrderanX);
  </code></pre>
  
  <p>it will return</p>
  
  <pre><code>[object Object],[object Object].[object Object]
  </code></pre>