0

I have an array that has values in some indexes now what i want to do is to change all values inside array to specific value for example 0, so how can i do that without looping i used bellow code but has syntax error, i don't know what is the syntax error here.

$my_array = array(
       'cen12' => 0,
       'cen67' => 1,
       'cen44' => 5
       );
$out_pot = array_map(function ($val){return 0;},$my_array);

Thanks for help!

Mobasher Fasihy
  • 1,021
  • 2
  • 9
  • 17

1 Answers1

0

The code above works well and returns

array(3) { ["cen12"]=> int(0) ["cen67"]=> int(0) ["cen44"]=> int(0) }
MDT
  • 1,599
  • 4
  • 18
  • 26