PHP: Collect all variables passed to a function as array?

Posted by Industrial on Stack Overflow See other posts from Stack Overflow or by Industrial
Published on 2010-06-01T22:14:12Z Indexed on 2010/06/01 22:23 UTC
Read the original article Hit count: 138

Filed under:
|
|
|
|

Hi everybody,

I was thinking about the possibility of accessing all the variables that are passed into an function, and merge them into an array. (Without passing variables into an array from the beginning)

Pseudo-code:

// Call function
newFunction('one', 'two', 'three' ) ;// All values are interpreted as a one rray in some way

// Function layout
newFunction( ) {    
   // $functionvariables =  array( All passed variables) 

    foreach ($functionvariable as $k => $v) {
        // Do stuff
    }
}

© Stack Overflow or respective owner

Related posts about php

Related posts about arrays