fork download
  1. <?php
  2.  
  3. $sales = array
  4. (
  5. 0 => array
  6. (
  7. 'orderCount' => 3,
  8. 'products' => 4,
  9. 'year' => 2014,
  10. 'month' => 11
  11. ),
  12. 1 => array
  13. (
  14. 'orderCount' => 1,
  15. 'products' => 2,
  16. 'year' => 2014,
  17. 'month' => 12
  18. )
  19. );
  20.  
  21. $month = array
  22. (
  23. 1 => 'Janv',
  24. 2 => 'Fév',
  25. 3 => 'Mars',
  26. 4 => 'Avr',
  27. 5 => 'Mai',
  28. 6 => 'Juin',
  29. 7 => 'Juil',
  30. 8 => 'Aout',
  31. 9 => 'Sept',
  32. 10 => 'Oct',
  33. 11 => 'Nov',
  34. 12 => 'Déc'
  35. );
  36.  
  37. $new = array_map(function($row) use($month) {
  38. $row['month'] = $month[$row['month']];
  39. return $row;
  40. }, $sales);
  41.  
  42.  
  43. var_dump($new);
Success #stdin #stdout 0.01s 20568KB
stdin
Standard input is empty
stdout
array(2) {
  [0]=>
  array(4) {
    ["orderCount"]=>
    int(3)
    ["products"]=>
    int(4)
    ["year"]=>
    int(2014)
    ["month"]=>
    string(3) "Nov"
  }
  [1]=>
  array(4) {
    ["orderCount"]=>
    int(1)
    ["products"]=>
    int(2)
    ["year"]=>
    int(2014)
    ["month"]=>
    string(4) "Déc"
  }
}