本文介绍了如何更改在PHP中的具体关联数组的价值呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经叫动态生成非常巨大的数组 $ test_package_data code>。您的理解,我给数组的内容如下
$ test_package_data code>。
I've a dynamically generated very huge array called $test_package_data
. For your understanding I'm giving below the contents of array $test_package_data
.
现在我想要实现的是转换一个数组键的值
Now what I want to achieve is convert the value of an array key
$test_duration = ConvertTimeStampToTimeFormate($some_key['test_duration']);
总之我想更新一键 ['test_duration']
eveywhere数组中的价值。但不理解我环路的阵列上,并应如何达到期望的结果。
In short I want to update the value of a key ['test_duration']
eveywhere in the array. But not understanding how should I loop over the array and achieve the desired result.
推荐答案
您可以使用并调整值,如果密钥匹配'test_duration
:
array_walk_recursive($test_package_data, function(&$value, $key) {
if ($key == 'test_duration') {
$value = ConvertTimeStampToTimeFormate($value);
}
});
这篇关于如何更改在PHP中的具体关联数组的价值呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!