Complete PHP Array Reference
The compact() function creates an array from variables and their values.
| 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. |
Note: Any strings that does not match variable names will be skipped.
The output of the code above will be:
Using a string that does not match a variable, and an array of variable names:
The output of the code above will be:
Complete PHP Array Reference
Your message has been sent to W3Schools.