gpt4 book ai didi

php - 如何将数组值转换为变量?

转载 作者:可可西里 更新时间:2023-10-31 22:54:16 25 4
gpt4 key购买 nike

我有两个数组。喜欢:

熊,王子,狗,葡萄牙,熊, clown ,王子,...

还有第二个:

45, 67, 34, 89, ...

我想把第一个数组中的字符串键变成变量,并设置它们相等到第二个数组中的数字。

这可能吗?

最佳答案

extract(array_combine($arrayKeys, $arrayValues));

http://php.net/array_combine
http://php.net/manual/en/function.extract.php

尽管我建议您将值保存在数组中,但用可变变量淹没您的命名空间很少是个好主意。

关于php - 如何将数组值转换为变量?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5786686/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com