Reputation: 137
I have simple questions, How to change text if id = cur_three from array below ?
$arr = array(
'id' => 'curr',
'lists' => array(
array(
'id' => 'cur_one',
'text' => 'Dollar',
),
array(
'id' => 'cur_two',
'text' => 'Euro',
),
array(
'id' => 'cur_three',
'text' => 'Peso',
),
)
);
Thank you very much...
Upvotes: 0
Views: 34
Reputation: 2564
Sure. Like this:
foreach($arr['lists'] as $key => $child) {
if($child['id'] == 'cur_three') {
$arr['lists'][$key]['text'] = "INR";
}
}
Upvotes: 0
Reputation: 2810
Something simple:
foreach($arr['lists'] as $subArr) {
if ($subArr['id'] == 'cur_three') {
$subArr['text'] = 'not Peso';
}
}
Upvotes: 1