PHP loop through a multidimensional array and change the values

I have a multidimensional array below, and I want to skip it and change the [menu_cats] value from a number to a string that is extracted from the database selection. Is it possible? The name of the array is "result".

Array ( [0] => Array ( [0] => Array ( [menu_cats] => 1 [item] => Introduction [link] => needs ) [1] => Array ( [menu_cats] => 1 [item] => Needs Assessment [link] => needs/needs.php ) ) [1] => Array ( [0] => Array ( [menu_cats] => 2 [item] => Introduction [link] => knowledge ) [1] => Array ( [menu_cats] => 2 [item] => Administer Knowledge Pre-Test [link] => knowledge/pre_test.php ) ) ) 
+7
source share
1 answer
 foreach($result as $key => $subarray) { foreach($subarray as $subkey => $subsubarray) { $result[$key][$subkey]['menu_cats'] = 'your string here'; } } 
+11
source

All Articles