fork(1) download
  1. <?php
  2.  
  3. $arr = ["Entrada" => 4, "Prato principal" => 1];
  4.  
  5. $res = array_reduce(array_keys($arr), function($novoArr, $chave) use ($arr){
  6. $novoArr[] = Array($chave, $arr[$chave]);
  7. return $novoArr;
  8. });
  9.  
  10. var_dump($res);
Success #stdin #stdout 0.02s 23900KB
stdin
Standard input is empty
stdout
array(2) {
  [0]=>
  array(2) {
    [0]=>
    string(7) "Entrada"
    [1]=>
    int(4)
  }
  [1]=>
  array(2) {
    [0]=>
    string(15) "Prato principal"
    [1]=>
    int(1)
  }
}