0

How can I make this work, I dont know why it's not working

public function generateCourse($course, $type) {
    $this->runFunction($this->generateHole($hole), $type);
}

public function runFunction($function, $type) {
        switch ($type){
            case 0:
                for ($hole = 0; $hole < 18; $hole++) {
                    $function;
                }
                break;
3
  • 1. this work What should it do? 2. it's not working What does that mean? Do you get any errors? wrong results? Commented Feb 18, 2015 at 12:38
  • possible duplicate of PHP pass function as param then call the function? Commented Feb 18, 2015 at 12:38
  • Please add what the expected result should be, and what error messages you are encountering. It'll make it easier to understand your problem. Commented Feb 18, 2015 at 12:38

1 Answer 1

0

Try this

public function runFunction($function, $type) {
        switch ($type){
            case 0:
                for ($hole = 0; $hole < 18; $hole++) {
                    $function();
                }

or call the function with this

call_user_func($function);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.