如何使用PHP更改数组中的值?
我有这样一个数组:如何使用PHP更改数组中的值?,php,arrays,Php,Arrays,我有这样一个数组: Array ( [error] = Array ( [0] = Password field is required. [1] = Sorry, unrecognized username or password. <a href="/user/password">Have you forgotten your password?</a> ) ) 数组 ( [错
Array
(
[error] = Array
(
[0] = Password field is required.
[1] = Sorry, unrecognized username or password. <a href="/user/password">Have you forgotten your password?</a>
)
)
数组
(
[错误]=数组
(
[0]=密码字段是必需的。
[1] =抱歉,无法识别的用户名或密码。
)
)
在上面的数组中,我需要在链接中添加一个类。我的预期输出应该是:
Array
(
[error] = Array
(
[0] = Password field is required.
[1] = Sorry, unrecognized username or password. <a href="/user/password" class="popups">Have you forgotten your password?</a>
)
)
数组
(
[错误]=数组
(
[0]=密码字段是必需的。
[1] =抱歉,无法识别的用户名或密码。
)
)
如何更改数组值?
$array['error'][1]=…
,但从声音上看,我认为您可能希望更改最初设置的值。在这种情况下,只需在代码中搜索对不起,无法识别的用户名或密码。
或其他内容
$somearray['somekey'] = 'newvalue';
$somearray['somekey']['otherkey'] = 'othernewvalue';
。。。基本PHP…在将链接打印到页面之前,可以在其上使用str_replace之类的函数