fork download
  1. <?php
  2. $a = array('aa','bb','cc','dd');
  3.  
  4. function addRq($sValue) {
  5. return [
  6. 'rq' => 'rq'.$sValue,
  7. 's' => $sValue
  8. ];
  9. }
  10. $newA = array_map("addRq", $a);
  11. var_dump($newA);
  12.  
Success #stdin #stdout 0.04s 25628KB
stdin
Standard input is empty
stdout
array(4) {
  [0]=>
  array(2) {
    ["rq"]=>
    string(4) "rqaa"
    ["s"]=>
    string(2) "aa"
  }
  [1]=>
  array(2) {
    ["rq"]=>
    string(4) "rqbb"
    ["s"]=>
    string(2) "bb"
  }
  [2]=>
  array(2) {
    ["rq"]=>
    string(4) "rqcc"
    ["s"]=>
    string(2) "cc"
  }
  [3]=>
  array(2) {
    ["rq"]=>
    string(4) "rqdd"
    ["s"]=>
    string(2) "dd"
  }
}