如何数组转换为在PHP中多个变量 [英] How to convert array to multiple variables in PHP
本文介绍了如何数组转换为在PHP中多个变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个数组:
$r = array(1,2,42,55);
和我想打电话给加密();的函数=http://www.hashids.org/php/相对=nofollow > hashids
and I want to call encrypt();
function of hashids
这需要输入这样的:
encrpyt(1,2,42,55);
我试过提取物($ R)
,但它不工作。
推荐答案
<击>这是丑陋的,但有这样的:击>
<击>的eval(加密(内爆(,$ R));); 击>
<击>这是你的义务提醒 EVAL 是潜在的危险和应很少,如果使用! 罢工>
Here's your obligatory reminder that eval is potentially dangerous and to be used rarely if ever!
编辑:忘了 call_user_func_array 。这是你的答案!示例code:
Forgot about call_user_func_array. That's your answer! Sample code:
$r = array(1,2,42,55);
$hashids = new Hashids\Hashids('this is my salt');
$hash = call_user_func_array(array($hashids, "encrypt"), $r);
这篇关于如何数组转换为在PHP中多个变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文