Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If this array was assigned to variable <code>$ary</code> like:</p> <pre><code>$ary = array( 'estimated' =&gt; array( array('TITLE' =&gt; 'MAIN', 'CURR_PERF' =&gt; 100, 'POT_PERF' =&gt; 75), array('TITLE' =&gt; 'HEAT', 'CURR_PERF' =&gt; 90, 'POT_PERF' =&gt; 60), array('TITLE' =&gt; 'CO2', 'CURR_PERF' =&gt; 56, 'POT_PERF' =&gt; 40), ), 'actual' =&gt; array( array('TITLE' =&gt; 'MAIN', 'CURR_PERF' =&gt; 100, 'POT_PERF' =&gt; 75), array( 'TITLE' =&gt; 'HEAT', 'CURR_PERF' =&gt; 89 , 'POT_PERF' =&gt; 75), array( 'TITLE' =&gt; 'CO2', 'CURR_PERF' =&gt; 40, 'POT_PERF' =&gt; 20 ), ); ); </code></pre> <p>Your <code>estimated</code> array could be accessed like:</p> <pre><code>$newVar = $ary['estimated'][2]['CURR_PERF']; </code></pre> <p><code>$newVar</code> would be <code>56</code>. You can reassign a value as well, like:</p> <pre><code>$ary['estimated'][0]['POT_PERF'] = 300; </code></pre> <p>That first array in the <code>estimated</code> array used to be <code>75</code> and is now <code>300</code>.</p> <p>This is how you get and set specific values in a Multi-dimensional Array.</p> <p>To sort the arrays, if you need to loop over and maintain their indexes, see PHP's <code>uasort()</code> function. This may take some work, on your part, to develop a <code>cmp_function</code>, but should do what you're looking for in a different way.</p> <p>See, </p> <p><a href="http://www.php.net/manual/en/function.uasort.php" rel="nofollow">http://www.php.net/manual/en/function.uasort.php</a></p> <p>and</p> <p><a href="http://www.php.net/manual/en/function.usort.php" rel="nofollow">http://www.php.net/manual/en/function.usort.php</a> ,</p> <p>which explains <code>cmp_function</code> better.</p>
    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. This table or related slice is empty.
    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