Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8381093
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T16:37:13+00:00 2026-06-09T16:37:13+00:00

Did my research on this, couldn’t find what I was looking for. Tried ReflectionClass

  • 0

Did my research on this, couldn’t find what I was looking for. Tried ReflectionClass but that didn’t work for me.

I have a class with functions. The number of variables going into the function is dynamic.

Example:

Included class:

class Home {
  function test($var1, $var2, $var3){
    // do stuff here
  }
}

// this class is included based on url params, i.e. example.com/home/test/1/2/3
// where home is class, test is function and 1 2 3 are variables

$variables = array('1','2','3'); // static for this example, but array can have any number of elements to it.

$foo = new Home();
$foo->test($variables);

call_user_func_array('test', $variables);

So what I am trying to achieve, is to take the array of variables and send them to the function test as so in the code example, where I can list each one.

This example below does what I would like to do, but how would I apply it to a class/mvc framework?

$colors = array('test','maroon','blue','green');
call_user_func_array('setLineColor', $colors);

function setLinecolor($var1, $var2, $var3, $var4){
  echo $var1;
  echo $var2;
}

Any thoughts on this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T16:37:14+00:00Added an answer on June 9, 2026 at 4:37 pm

    Use a proper callback for the object:

    $foo = new Home();
    call_user_func_array( array( $foo, 'test'), $variables);
    

    This will invoke the test() function on the $foo object.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I did some research but couldn't find the answer I was looking for so
I did a lot of research on this subject but couldn't find any end
Alright I did a little bit of research on this but I couldn't find
I did a series of research on this topic, but unfortunately I couldn't find
I did some research but all I could find was syncing data core with
I did some research but cannot find a definite approval or disapproval. What I
I did a little research and I didn't find a way, anyone know? c#
This is a homework problem that I have. I have been doing some research
well i did my research and seen a lot of posts about this but
I did some research and couldn't find a suitable answer so I'm reaching out.....

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.