Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $actions = array(
- array('action' => 'Action1', 'value' => '0'),
- array('action' => 'Action2', 'value' => '0'),
- );
- foreach($actions as $item){
- if($item['action'] == 'Action1'){
- $item['value'] = 20;
- }
- }
- foreach ($actions as &$item) {
- }
- foreach($actions as $key => $val){
- if($val['action'] == 'Action1'){
- $actions[$key]['value'] = 20;
- }
- }
- foreach($actions as &$item){ //<== add "&" reference to the $item that now when ever you change it the actions will change
- if($item['action'] == 'Action1'){
- $item['value'] = 20;
- }
- }
- foreach($actions as $key => $item){
- if($item['action'] == 'Action1'){
- $actions[$key]['value'] = 20; // directly access $action and modify the value
- }
- }
- foreach(array_keys($actions) as $key){
- $item = &$actions[$key];
- if($item['action'] == 'Action1'){
- $item['value'] = 20;
- }
- }
- foreach($actions as &$item)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement