Created
September 28, 2015 22:22
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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