PHP按键替换数组值

时间:2021-03-23 22:08:19

I have an array:

我有一个数组:

 Array
(
    [0] => Array
        (
            [id] => 11
            [email_theme_id] => 1_5
            [email_template] => Array()
            [add_template] => 
            [email_template_subject] => Your free and bargain ebook alert for Sunday
            [last_update] => 1392314609
        )

    [1] => Array
        (
            [id] => 10
            [email_theme_id] => 2_12
            [email_template] => Array()
            [add_template] => 
            [email_template_subject] => Your free and bargain ebook alert for Sunday
            [last_update] => 1392314609
        )

)

and I need to change Array item [1] [email_template] value, so how should I do It with PHP?

我需要更改数组项[1] [email_template]值,那么我应该如何使用PHP?

2 个解决方案

#1


0  

Try like

试试吧

$item[1][email_template] = array('new value');

Or even you can do like

或者甚至你可以做到

$item[1][email_template][0] = 'new value';

Considering that you want to update the array

考虑到您要更新阵列

#2


1  

Just try with:

试试:

$data[1]['email_template'] = 'new value';

Where $data is your data variable.

其中$ data是您的数据变量。

#1


0  

Try like

试试吧

$item[1][email_template] = array('new value');

Or even you can do like

或者甚至你可以做到

$item[1][email_template][0] = 'new value';

Considering that you want to update the array

考虑到您要更新阵列

#2


1  

Just try with:

试试:

$data[1]['email_template'] = 'new value';

Where $data is your data variable.

其中$ data是您的数据变量。