How to extract data from df -h in php?
<p>I need to build a script that will query a remote storage server with multiple drives for their free space. </p>

<p>I simply login with SSH, run <code>df</code> and throw the output into a variable. Which looks like this:</p>

<pre><code>    Array
(
    [0] =&gt; Filesystem           1K-blocks      Used Available Use% Mounted on
    [1] =&gt; /dev/sda1             59392320  14949240  41426064  27% /
    [2] =&gt; /dev/sdd1            140592240 114503840  18946708  86% /home/overflow
    [3] =&gt; /dev/sdf1            287826944 273844324         0 100% /home/node2
    [4] =&gt; /dev/sde1            287826944 253278964  19927228  93% /home/node3
    [5] =&gt; /dev/sdg1            287826944   4771768 268434424   2% /home/node4
    [6] =&gt; /dev/sdh1            287826944   4329780 268876412   2% /home/node5
    [7] =&gt; /dev/sdi1            488302976 439077756  24420864  95% /home/node1
    [8] =&gt; /dev/sdh1            287826944   4329780 268876412   2% /home/mnode6
    [9] =&gt; /dev/sdh1            287826944   4329780 268876412   2% /home/mnode7
    [10] =&gt; tmpfs                  3145728         0   3145728   0% /tmp
)
</code></pre>

<p>I need to extract how much free space each "node" or "mnode" has. So perhaps a nice array that has pairs such as this:</p>

<pre><code>mnode1 =&gt; 24000000
node1 =&gt; 24000000
node2 =&gt; 0
node3 =&gt; 20000000
</code></pre>
