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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T04:41:26+00:00 2026-06-14T04:41:26+00:00

I have a script where it accepts a varying number of arguments. I want

  • 0

I have a script where it accepts a varying number of arguments.

I want to use func_get_args to perform operations on said arguments. If I have one function like this:

function Something() {
   foreach(func_get_args($this) as $functions) {
       // Do something
   }

   // Return..
}

I want to be able to call this function in, for example, another function to add/save entries. The add/save function would have arguments ‘title’, ‘description’ etc..

I basically want to know if there is a way to detect the context of a function call. Can I pass something to func_get_args that will let it know that its called in a certain function? So if I do:

function Save($title, $desc) {
$vars = $this->Something();
}

I want $vars to contain $title and $desc after modifying them.

  • 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-14T04:41:27+00:00Added an answer on June 14, 2026 at 4:41 am

    Figured it out.. Not pretty, but it does what I want it to.

    private function Handle($Function, $Values) {
            $Method = new ReflectionMethod($this, $Function);
            $Result = array();
            $Inc = 0;
    
            foreach($Method->getParameters() as $Args) {
                $Result[$Args->getName()] = $this->DB->real_escape_string($Values[$Inc]);
                $Inc++;
            }
    
            return $Result;
    }
    
    function Test($a, $b, $c) {
        $Vars = $this->Handle(__FUNCTION__, func_get_args());
        print_r($Vars);
    }
    
    print_r(Test(1, 2, 3));
    
    Array
    (
        [a] => 1
        [b] => 2
        [c] => 3
    )
    

    I had another way of doing this but the array had to be accessed using $Vars[0], $Vars[1], etc, and I wanted to make it so I could use $Vars['something'], $Vars['something_else'].

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

Sidebar

Related Questions

I have a matlab script lets say image_process.m and the function image_process accepts one
I have a script that accepts XML input, and I want to convert it
I have a perl script that accepts a long option like --pager='less -R' and
If I have a function which accepts more than one string parameter, the first
I have been unable to create a Powershell function that accepts more than one
Here's my situation. Currently, I have a script that accepts two arguments: book name
I have script like this : fullscript.sh if [ ! -f /opt/laks/linux-2.6.33.2.tar.bz2 ] then
I have a Python script which accepts a XML file as input and then
I have a small python cgi script that accepts an image upload from the
I'm trying to write a simple bash script that accepts all arguments and interprets

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.