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

  • Home
  • SEARCH
  • 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 9115365
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T04:24:51+00:00 2026-06-17T04:24:51+00:00

I need to create a function which will have large amount of parameters can

  • 0

I need to create a function which will have large amount of parameters can be null or value. Now I am creating function as below example:

function container($args){

    $args += array(
            'limit'             =>      10,
            'container'         =>      null,
            'container_class'   =>      null,
            'list_class'        =>      null,
        );

    echo'<'.$args['container'].' class="'.$args['container_class'].'" >';

    echo 'My function will have other content here with the '.$args['limit'];

    echo '<ul class="'.$args['list_class'].'" >';
    echo '<li>list itme here</li>';
    echo '</ul>'

    echo '</'.$container.'>';    

}

This is fine if I have to pass 4-5 value in array but what if I have more than 15-20 key to pass? There must be some appropriate way to achieve.

So how can I create a function in such efficient way to pass many array key as a parameters?

Thanks a lot

  • 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-17T04:24:52+00:00Added an answer on June 17, 2026 at 4:24 am

    15-20 keys is not really a big array. When you need to think about how to pass something into args it’s when you have 1000+ keys.

    Anyway you can use “Passing by reference” concept (see http://php.net/manual/en/language.references.pass.php). This concept is useful when you have to modify the variable into function without any returning statment.
    But to achieve this goal, instead of sending a copy of your variable, PHP just send a key that reference the variable in memory.

    And this key does not depend of the size of the variable.

    How to use? By using & symbol in your function declaration
    ex:

    function container(&$args) 
    {
        // your function
    }
    
    $args = array(1, 2, 3 ..., 100000);
    container($args);
    

    But if you use “Passing by reference” concept be careful to do not modify the $args or $args will be modify on the main script.

    Final world: if you have less than 50 keys do not care about how to pass your args, just use by copy (default behavior) will be safer!

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

Sidebar

Related Questions

I need to create module in Magento which will have few database tables. One
I need to create a webpage which will have following features: It will have
I need a function which will create a file with fixed size in linux.
I need to create a WCF Service that will have a download file function.
I need to create a function which rounds decimal numbers like this: Round($32.95, 0)
I need to be able to create a seperate function which creates a total
I need to create a function that uses a loop. This function will open
I need to create a function that takes month and year as parameters and
I need to create a sub-function that will return me all the adjacent node,
Basically I need to create a textarea that is character limited, but will have

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.