doulieyu0881 2014-09-19 07:04
浏览 97
已采纳

在PHP中将数组作为参数传递非用户函数

I have the following code:

$bin = "\x04\x00\xa0\x00\x04\x00\xa0\x00";
$unpack_data = unpack("C*", $bin);
$arr = array($unpack_data[1], $unpack_data[2], $unpack_data[3]);

How can I pass an array $arr to a pack() function? The only thing that I can make:

$res = pack("C*", $unpack_data[1], $unpack_data[2], $unpack_data[3]);

but the length and content of the array are getting in the course of the program.

  • 写回答

3条回答 默认 最新

  • dongxu2398 2014-09-19 07:07
    关注

    Like this:

    call_user_func_array('pack', array_merge(['C*'], $unpack_data))
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?