title: How to send array and variable from php to android app?
body: <p>I need help.
  Have seen similar questions but I cant still do it. So I post mine.
  php codes runs well so far. Ijust dont know how to get the array.
  How can I get the array from php and list it in my alertdialog like this:</p>
  
  <pre><code>soy sauce - $1
  onion - $1
  total= $2
  </code></pre>
  
  <p>Or is this possible or not? Or maybe please tell me what to add in here. 
  Thanks for your time in advance. Any form of help would be appreciated.</p>
  
  <p>This are my codes:</p>
  
  <pre><code>public class updateData2 extends AsyncTask&lt;String, String, String&gt; {
  
      @Override
      protected String doInBackground(String... params) {
  
  
          ArrayList&lt;NameValuePair&gt; postVars = new ArrayList&lt;&gt;();
          postVars.add(new BasicNameValuePair("JSON", String.valueOf(EverythingJSON)));
          HttpClient httpclient = new DefaultHttpClient();
          HttpPost httppost = new HttpPost("http://abcabc.com/buy_now.php");
  
  
          try {
              httppost.setEntity(new UrlEncodedFormEntity(postVars));
          } catch (UnsupportedEncodingException e) {
              e.printStackTrace();
          }
          try {
              HttpResponse response = httpclient.execute(httppost);
              String responseBody = EntityUtils.toString(response.getEntity());
          } catch (ClientProtocolException e) {
              e.printStackTrace();
              Log.v("MAD", "Error sending... ");
          } catch (IOException e) {
              e.printStackTrace();
              Log.v("MAD", "Error sending... ");
          }
          return null;
  
      }
  
      @Override
      protected void onPostExecute(String result) {
          Toast.makeText(Cart.this,EverythingJSON.toString(), Toast.LENGTH_LONG).show();
  
  
          AlertDialog.Builder builder = new AlertDialog.Builder(Cart.this);
          builder.setTitle("ORDER:");
          builder.setMessage(EverythingJSON.toString());
  
          builder.setPositiveButton("Confirm",
                  new DialogInterface.OnClickListener()
                  {
                      public void onClick(DialogInterface dialog, int id)
                      {
  
                      }
                  });
  
          builder.show();
  
      }
  
  
  }
  </code></pre>
  
  <p>php</p>
  
  <pre><code>    &lt;?php 
  require "conn.php";
  $total = 0;
  // $ing = array("ampalaya", "soy sauce");
  $JSON_Received = $_POST["JSON"];
  $obj = json_decode($JSON_Received, true);
  
  $products_name_array = array();
  $products_price_array = array();
  
  // foreach($ing as $value){
  
  foreach($obj['ques'] as $value){
  
      $sql="select MIN(product_price) , product_id , store_id , product_name,product_unit_of_measure , product_price ,product_stock  from products where product_name like '%$value%'";
  
      $result2 = mysqli_query($conn, $sql);
  
      if(mysqli_num_rows($result2) &gt; 0){
          while($row = mysqli_fetch_assoc($result2)){
  
              $product_id=$row['product_id'];                           
              $store_id=$row['store_id'];                                 
              $product_name=$row['product_name'];                         $products_name_array[] = $product_name;
              $product_unit_of_measure=$row['product_unit_of_measure'];   
              $product_price=$row['product_price'];                       $products_price_array[] = $product_price;
  
              $total = $total+$product_price;
  
          }}
  
   }
  foreach($products_name_array as $key =&gt; $value) {
      echo $products_name_array[$key] . " -    " . "$" . $products_price_array[$key] . ".00" ."&lt;br&gt;";
  }
  
  
       echo "&lt;/br&gt;";  
       echo "&lt;/br&gt;";  
       echo "TOTAL IS:   ".$total. ".00"; 
       ?&gt;
  </code></pre>