duanjiangzhi6851 2016-10-03 22:09
浏览 53

将“do_action”插入到特定索引(PHP)的数组中

Has anyone ever been able to insert the output from do_action into an array at a specific index? For example, if you have the array and function below:

$myarr = array(1,2,3,4);

 my_function(){
  return 4 + 4;
}

I'm trying to do:

array_splice($myarr, 2, 0, do_action('my_function'););

And have it output:

[1, 2, 8, 3, 4]

I'm trying to integrate something like this in a wordpress page, and it breaks my entire page.

  • 写回答

1条回答

  • dqmq0654 2016-10-03 22:19
    关注

    If that's your exact code then the problem is here

    array_splice($myarr, 2, 0, do_action('my_function'););
    

    correct line is

    array_splice($myarr, 2, 0, my_function());
    
    评论

报告相同问题?

悬赏问题

  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程
  • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
  • ¥15 关于smbclient 库的使用