Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在PHP中将数组转换为多个变量_Php_Arrays_Hash - Fatal编程技术网

如何在PHP中将数组转换为多个变量

如何在PHP中将数组转换为多个变量,php,arrays,hash,Php,Arrays,Hash,我有一个数组: $r = array(1,2,42,55); 我想调用encrypt()功能 它需要这样的输入: encrpyt(1,2,42,55); 我尝试了提取($r),但没有成功。您可以对数组的每个元素调用回调。检查它是否有用。它很难看,但有一点: eval(“加密(“.intlode(“,”,$r)。”);” 这里是你的强制性提醒,这是潜在的危险,如果有机会的话,很少使用 编辑:忘了。这就是你的答案!示例代码: $r = array(1,2,42,55); $hashids = n

我有一个数组:

$r = array(1,2,42,55);
我想调用
encrypt()功能

它需要这样的输入:

encrpyt(1,2,42,55);

我尝试了提取($r)
,但没有成功。

您可以对数组的每个元素调用回调。检查它是否有用。

它很难看,但有一点:

eval(“加密(“.intlode(“,”,$r)。”);”

这里是你的强制性提醒,这是潜在的危险,如果有机会的话,很少使用

编辑:忘了。这就是你的答案!示例代码:

$r = array(1,2,42,55);
$hashids = new Hashids\Hashids('this is my salt');
$hash = call_user_func_array(array($hashids, "encrypt"), $r);

我想你应该加密数组值,而不是数组!!是的,这就是我想从数组中提取值的原因。看起来不错。谢谢我现在没有时间尝试,我会尽快尝试。好的,如果它对您有效,请不要忘记标记为已接受。值得注意的是<代码>$hashids->encrypt(…$r)