code: public static function memory() 
      {
          $memory         = new \StdClass();
          $memory->real   = new \StdClass();
          $memory->swap   = new \StdClass();
          
          if(false !== ($data = @file('/proc/meminfo'))){
              
              $data = implode("", $data);
              
              //processing and stuff aka preg matching
              preg_match_all("/MemTotal\s{0,}\:+\s{0,}([\d\.]+).+?MemFree\s{0,}\:+\s{0,}([\d\.]+).+?Cached\s{0,}\:+\s{0,}([\d\.]+).+?SwapTotal\s{0,}\:+\s{0,}([\d\.]+).+?SwapFree\s{0,}\:+\s{0,}([\d\.]+)/s", $data, $meminfo);
      	    preg_match_all("/Buffers\s{0,}\:+\s{0,}([\d\.]+)/s", $data, $buffers);
      	    
      	    $memory->total          = $meminfo[1][0]*1024;
      	    $memory->free           = $meminfo[2][0]*1024;
      	    $memory->used           = $memory->total - $memory->free;
  	        $memory->cached         = $meminfo[3][0]*1024;
      	    $memory->buffers        = $buffers[1][0]*1024;
      	    
      	    $memory->real->used     = $memory->total - $memory->free - $memory->cached - $memory->buffers;
      	    $memory->real->free     = $memory->total - $memory->real->used;
      	    
      	    $memory->swap->free     = $meminfo[5][0]*1024;
      	    $memory->swap->used     = $meminfo[4][0]*1024 - $memory->swap->free;
      	    
          }
  
          return $memory;
          
      }
docs: Server memory information
  @return \StdClass
  ->total
  ->used
  ->free
  ->cached
  ->buffers
  ->real->used
  ->real->free
  ->swapo->used
  ->swapo->free
  @important: all data is in bytes