Skip to content

Instantly share code, notes, and snippets.

@phpfiddle
Created September 28, 2015 22:22
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save phpfiddle/f03f71155c59f08056d6 to your computer and use it in GitHub Desktop.
Save phpfiddle/f03f71155c59f08056d6 to your computer and use it in GitHub Desktop.
[ Posted by Swathi Paipalle ] Loop Through Multi dimensional array and change value - php
<?php
$result = array
(
array
(
array
(
'menu_cats' => 1,
'item' => 'Introduction',
'link' => 'needs'
),
array
(
'menu_cats' => 1,
'item' => 'Needs Assessment',
'link' => 'needs/needs.php'
)
),
array
(
array
(
'menu_cats' => 2,
'item' => 'Introduction',
'link' => 'knowledge'
),
array
(
'menu_cats' => 2,
'item' => 'Administer Knowledge Pre-Test',
'link' => 'knowledge/pre_test.php'
)
)
);
foreach($result as $key => $subarray) {
foreach($subarray as $subkey => $subsubarray) {
$result[$key][$subkey]['menu_cats'] = 'your string here';
}
}
echo '<pre>'.print_r($result).'</pre>';
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment