title: Php Exec - System RAM
body: <p>I have been searching for a couple of days, and I know what needs to be done, but cannot figure out the exact code. I know it has to use preg_match in order for me to get exactly what I want, but I am having trouble with that.</p>
  
  <p>I am trying to have a script show how much RAM is used on the system. I am using php exec. I use the command free -mt. Online, I did manage to find this code and I made a slight modification.</p>
  
  <p><code>
  exec('free -mo', $out);<br>
  var_dump($out[1]);<br>
  list($mem, $used, $free, $shared, $buffers, $cached) = explode(" ", $out[1]);<br>
  echo "Memory: " .$used. "/" . $total;
  </code></p>
  
  <p>What do I need to do if I just want to output the amount of RAM currently used?</p>
  
  <p>The code ends of showing all RAM, but I need it to just show the total used amount of RAM. My output I get from that code is:</p>
  
  <p><code>
  string(73) "Mem: 768 162 605 0 0 0" Memory: /
  </code></p>
  
  <p>I would like it to just say the RAM being used, so, it should come out saying 162 during this exact moment, but it should be real data every time it is refreshed.</p>