0

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...

2 Answers 2

1

Something simple:

foreach($arr['lists'] as $subArr) {
    if ($subArr['id'] == 'cur_three') {
        $subArr['text'] = 'not Peso';
    }
}
Sign up to request clarification or add additional context in comments.

Comments

0

Sure. Like this:

foreach($arr['lists'] as $key => $child) {

    if($child['id'] == 'cur_three') {
        $arr['lists'][$key]['text'] = "INR";
    }

}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.