更新时间:2023-11-07 09:34:34
虽然没有一个等效于示例代码的函数,但是您可以使用 array_keys
(带有可选的搜索值参数), array_fill
和 array_replace
来实现同一目的:
While there isn't one function equivalent to the sample code, you can use array_keys
(with the optional search value parameter), array_fill
and array_replace
to achieve the same thing:
Tomas的编辑:该代码无法正常工作,已更正:
EDIT by Tomas: the code was not working, corrected it:
$ar = array_replace($ar,
array_fill_keys(
array_keys($ar, $value),
$replacement
)
);