我爱占星网 我爱占星网
首页
编程
java
php
前端
首页 编程 java php 前端

Make for循环函数运行另一个函数

Is possible to make for loop function for php, that works like this

function hit(){

}

function forLoop($function, $times) {

for($x = 0; $x < $times; $x++) {
    $function;
}

$this->forLoop($function, 5);

This can be done with the call_user_func function:

function hit(){
    echo "hello !";
}

function forLoop($function, $times) {

    for($x = 0; $x < $times; $x++) {
        call_user_func($function);
    }
}

forLoop('hit', 5);

近期文章

  • 在客户端和php服务器之间发送json数据
  • phpMyAdmin - 会话启动时出现错误Mysql错误
  • 停止转义列名codeigniter活动记录
  • 如何以逗号分隔显示多行数据
  • 如何在单个变量中追加不同的Array值
  • PHP根据参数更改目录(来自url的$ GET)
  • 服务器上的写入文件无效,权限问题?
  • 将文件加载到表中,然后更新最后输入的行
  • 我正在尝试插入SQL查询,但没有插入数据库
  • PHP邮件功能不工作bur发送核心php没有错误[重复]
  • UTC一个月的日期
  • PHP非法字符串
  • Socks5多个请求
  • 如何从C中的apache CGI进程中分离独立的PHP进程?
  • PHP - 将数据导出到excel
  • PHP - 我无法保存任何文件
  • 多个PHP网页合二为一
  • 无法从XAMPP加载.jpg
  • 正则表达式从源代码中选择div
  • JQuery Autocomplete不能使用PHP

Copyright ©2022 我爱占星 All Rights Reserved.

浙ICP备2022030071号-1

部分图文来自网络,如有侵犯您的版权,请告诉我们删除

友情链接:代码精华