fork download
  1. <?php
  2.  
  3. $dados = array
  4. (
  5. 0 => 'MemTotal: 4060964 kB',
  6. 1 => 'MemFree: 3630320 kB',
  7. 2 => 'MemAvailable: 3789472 kB',
  8. 3 => 'Buffers: 93040 kB',
  9. 4 => 'SwapCached: 0',
  10. 6 => 'Active: 306312 kB'
  11. );
  12.  
  13.  
  14. $dadosNew = array();
  15. foreach($dados as $key => $value)
  16. {
  17. $valueNew = explode(":", $value);
  18. $dadosNew[$valueNew[0]] = trim($valueNew[1]);
  19. }
  20.  
  21. var_dump($dadosNew);
Success #stdin #stdout 0s 52488KB
stdin
Standard input is empty
stdout
array(6) {
  ["MemTotal"]=>
  string(10) "4060964 kB"
  ["MemFree"]=>
  string(10) "3630320 kB"
  ["MemAvailable"]=>
  string(10) "3789472 kB"
  ["Buffers"]=>
  string(8) "93040 kB"
  ["SwapCached"]=>
  string(1) "0"
  ["Active"]=>
  string(9) "306312 kB"
}