Create an array from variables and their values:
The compact() function creates an array from variables and their values.
Note: Any strings that does not match variable names will be skipped.
Parameter | Description |
---|---|
var1 | Required. Can be a string with the variable name, or an array of variables |
var2,... | Optional. Can be a string with the variable name, or an array of variables. Multiple parameters are allowed. |
Return Value: | Returns an array with all the variables added to it |
---|---|
PHP Version: | 4+ |
Using a string that does not match a variable, and an array of variable names: