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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T12:41:20+00:00 2026-06-07T12:41:20+00:00

Let say i have function: <?php function myFunction($param1, $param2, /*0 or more extra args*/)

  • 0

Let say i have function:

<?php
function myFunction($param1, $param2, /*0 or more extra args*/) {
  // do something with $param1 & $param2
  $args = func_get_args();
  $other_args = array_slice($args, 2); // get the dynamic args
  // do something with $other_args
}
?>

this enables to call:

<?php
myFunction($param1, $param2); // or
myFunction($param1, $param2, $param3); // or
myFunction($param1, $param2, $param3, $param4);
?>

But i want to know if it possible to to take an array of args and pass them into the function e.g:

<?php
$extra_args = array($param3, $param4); // this could also be
$extra_args = array($param3, $param4, $param5); // or any length array
?>

i would like to pass them as separate params into my function e.g

<?php
myFunction($param1, $param2 /* other args split up */);
?>

Thanks in advance!

  • 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-07T12:41:22+00:00Added an answer on June 7, 2026 at 12:41 pm

    Yeap – call_user_func_array()‘.

    http://www.php.net/manual/en/function.call-user-func-array.php

    Takes two arguments – the function name (as a string – or possibly, in PHP >= 5.3, an anonymous function, not sure) and an array of params.

    Or for methods, forward_static_call_array()

    http://www.php.net/manual/en/function.forward-static-call-array.php

    PHP’s answer to JS’s function.prototype.apply() 🙂

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

Sidebar

Related Questions

Let's say I have something like this: <?php namespace Twitter; class Twitter { function
Let's say i have this php function called from multiple php files do_something($var); How
Let's say I have a 200x100px picture. Is there any PHP function or PHP
Let's say I have this script: $('.myDiv').click(function(){ $.getJSON('http://example.com/t.php', { department: 'department', manufacturer: '' }
I have a problem here with the php function substr Let's say I have
Let's say I have the following scenario: <form action=/something.php method=GET>Click me</div> <script type=text/javascript><!-- $('form').submit(function(e)
let say i have function like below function doSomethingNow(){ callSomethingInFutureNotExistNow(); } at the moment
Let's say we have the following function: foo <- function(x) { line1 <- x
Let's say I have a 1D Gaussian function. Its length is 600. I want
Let's say I have this $(document).ready(function() { var array = $.makeArray($('p')); $(array).appendTo(document.body); }); });

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.