Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The best way to do this is to json_encode the array and then echo the result out to the JavaScript/jQuery:</p> <p><a href="http://php.net/manual/en/function.json-encode.php" rel="nofollow">json_encode PHP function</a></p> <p>Here is the PHP <a href="http://codepad.org/kPKZkTD4" rel="nofollow">php demo</a></p> <pre><code>&lt;?php $myarray = Array ( Array ( 'image' =&gt; 'article_list1.png', 'title' =&gt; 'Everyone involved in OMS in Ghent' ), Array ( 'image' =&gt; 'article_list1.png', 'title' =&gt; 'Everyone involved in OMS in Ghent' ), Array ( 'image' =&gt; 'article_list1.png', 'title' =&gt; 'Everyone involved in OMS in Ghent' ), Array ( 'image' =&gt; 'article_list1.png', 'title' =&gt; 'Everyone involved in OMS in Ghent' ), Array ( 'image' =&gt; 'article_list1.png', 'title' =&gt; 'Everyone involved in OMS in Ghent' ), Array ( 'image' =&gt; 'article_list1.png', 'title' =&gt; 'Everyone involved in OMS in Ghent' ) ); echo json_encode($myarray); ?&gt; </code></pre> <p>This should give you something like this:</p> <pre><code>[{"image":"article_list1.png","title":"Everyone involved in OMS in Ghent"},{"image":"article_list1.png","title":"Everyone involved in OMS in Ghent"},{"image":"article_list1.png","title":"Everyone involved in OMS in Ghent"},{"image":"article_list1.png","title":"Everyone involved in OMS in Ghent"},{"image":"article_list1.png","title":"Everyone involved in OMS in Ghent"},{"image":"article_list1.png","title":"Everyone involved in OMS in Ghent"}] </code></pre> <p>and to access it using jQuery <a href="http://jsfiddle.net/2gr2V/" rel="nofollow">jsfiddle demo</a>:</p> <pre><code>var myJson = '[{"image":"article_list1.png","title":"Everyone involved in OMS in Ghent"},{"image":"article_list1.png","title":"Everyone involved in OMS in Ghent"},{"image":"article_list1.png","title":"Everyone involved in OMS in Ghent"},{"image":"article_list1.png","title":"Everyone involved in OMS in Ghent"},{"image":"article_list1.png","title":"Everyone involved in OMS in Ghent"},{"image":"article_list1.png","title":"Everyone involved in OMS in Ghent"}]'; myJson = JSON.parse(myJson); for(var i=0; i&lt;myJson.length; i++) console.log(myJson[i].image+ ' ' + myJson[i].title); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload