Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>PHP can try to <a href="http://www.phpro.org/examples/Convert-Object-To-Array-With-PHP.html" rel="nofollow">cast objects into arrays</a> by itself, and for simple stuff, it usually works fine.</p> <p>As for multidimensional arrays, Javascript isn't too different from most other higher-level programming/scripting languages when it comes to arrays. Really, any tutorial online on multidimensional arrays will do just fine. A multidimensional array is simply an array of arrays.</p> <p>When you receive the string client-side, you just want to parse it. jQuery has <a href="http://api.jquery.com/jQuery.parseJSON/" rel="nofollow">its own method</a>, but you can use <a href="https://developer.mozilla.org/en/Using_native_JSON" rel="nofollow">JSON.parse</a>. Afterwards, based on how you've set up your arrays, you'd want to do something like this.</p> <pre><code>&lt;? $count = count($json_parsed['url']); for($i = 1; $i &lt; $count; $i++) : ?&gt; &lt;td&gt;&lt;?=$json_parsed['url'][$i];?&gt;&lt;/td&gt; &lt;td&gt;&lt;?=$json_parsed['anchor'][$i];?&gt;&lt;/td&gt; &lt;? endfor; ?&gt; </code></pre> <p>This may be philosophically not the best way to do it though. If you have a whole bunch of objects and you want to make a table out of them, the best way would be to create an array of those objects as represented by associative arrays (sort of like hash tables in other programming languages). PHP natively tries to convert objects into associative arrays. I wouldn't be surprised if <code>Zend_Json::encode</code> does it automatically. If it does, you might want to pull simply:</p> <pre><code>echo Zend_Json::encode($bk); </code></pre> <p>If not, let me know, and we'll talk about how to do that.</p>
 

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