title: PHP and Ajax using foreach loop in the callback and return array
body: <p>I'm trying to loop through the <strong>Callback</strong> from <strong>PHP</strong> result.</p>
  
  <p>But I can't or I don't know how to return an array as a <strong>Callback</strong></p>
  
  <p>This is my <strong>PHP</strong> code :</p>
  
  <pre><code>$id = $_GET['id'];
  
  $data = file_get_contents('__url');
  
  parse_str($data);
  
  $array = explode(',', $url_encoded_fmt_stream_map);
  
  foreach($array as $item) {
      parse_str($item);
      echo $_GET['callback']."(".json_encode($url).");"; // it should return an array at least 3 urls
  }
  </code></pre>
  
  <p>And this is my <strong>Jquery</strong> code :</p>
  
  <pre><code>$.ajax({
      url:"file.php",
      dataType: 'jsonp',
      data: {id: id},
      success:function(response){
          $('body').append(response);
      }
  });
  </code></pre>
  
  <p>It gives me one result only but it should return an array, it's working like I did not use <code>foreach</code> loop in the php code.</p>
  
  <p>I tested the <strong>PHP</strong> code without <strong>Ajax Request</strong> and it returned an array of urls, but if I used the ajax callback it's returning one url only.</p>