title: sort php json data in Javascript
body: <p>I want to sort php json data from multidimensional array using javascript or jquery
  my php is</p>
  
  <pre><code>$array = array();
  $x = 0;
  while($row = $get_images-&gt;fetch_assoc()){
      $name = $row['name'];
      $image_type = $row['image_type'];
      $caption = stripslashes($row['caption']);
      $arr = array('name' =&gt; $name, 'type' =&gt; $image_type, 'caption' =&gt; $caption);
      $array[] = $arr;
      //array_push($array, $$arr);
      $x++;
  }
  
  echo json_encode($array);
  </code></pre>
  
  <p>the result looks like this:</p>
  
  <pre><code>[{"name":"2323dffd","type":"jpg","caption":"ddd"},{"name":"323232323","type":"jpg","caption":"dddfdf"},{"name":"dffdd","type":"jpg","caption":"dfdfdfere"}]
  </code></pre>
  
  <p>I want append the data to a document prefebly using a while loop in javascript but I am not sure how to use the data from the json file (I am not sure if it is valid). I tried some solutions such as $.each but they did not work. This is my JS:</p>
  
  <p>$(function($){</p>
  
  <pre><code>    $.getJSON("http://www.xxxxx.com/json.php", function(json) {
          while(){
                        //your code here
                        $("#content").append(json...);
                      }
      });
  </code></pre>
  
  <p>});</p>