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 8543959
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T12:26:08+00:00 2026-06-11T12:26:08+00:00

In short, I have a function like the following: function plus($x, $y){ echo $x+$y;

  • 0

In short, I have a function like the following:

function plus($x, $y){
   echo $x+$y;
}

I want to tell the function its parameters as array like the following:

$parms = array(20,10);
plus($parms);

But unfortunately, not work.
I’m tired by using another way as the following:

$parms = array(20,10);
$func_params = implode(',', $parms);
plus($func_params);

And also not work, and gives me Error message:
Warning: Missing argument 2 for plus(), called in.....

And now, I’m at a puzzled.
What can I do to work ?

  • 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-11T12:26:09+00:00Added an answer on June 11, 2026 at 12:26 pm

    There is a couple things you can do.
    Firstly, to maintain your function definition you can use call_user_func_array(). I think this is ugly.

    call_user_func_array('plus', $parms);
    

    You can make your function more robust by taking a variable number of params:

    function plus(){
      $args = func_get_args();
      return $args[0] + $args[1];
    }
    

    You can simply accept an array and add everything up:

    function plus($args){
      return $args[0] + $args[1];
    }
    

    Or you could sum up all arguments:

    function plus($args){
      return array_sum($args);
    }
    

    This is PHP, there are 10 ways to do everything.

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

Sidebar

Related Questions

I want to call the following function from my managed code: short LS_LoadConfig(LS_ID SensorID,LPVARIANT
I have the following function for using ZenDesk. I'd like to inject my current_user
I am writing a function short getBits(short data, int p, int n) I have
I have some sort of recursive function, but I need to parse a string,
I have the following function for reading a big-endian quadword (in a abstract base
I have the following C function: int w_ei_connect_init(ei_cnode* ec, const char* this_node_name, const char
for short, this could be paraphrased like inheritance versus function library for example, I'd
I have the following function that was originally being invoked from the UI (Main)
I have the following Javascript: function TestModel() { this.name = Testvalue; this.id = 0;
I have some code which takes a short while to complete. I'd like it

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.