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条)

报告相同问题?

悬赏问题

  • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效