| Previous | Home | Next |
array_compact()
The compact() function creates an array from variables and their values.
Syntax:compact(var1,var2...)
In above syntax, "var1" can be a string with the variable name, or an array of variables and "var2,..." can be a string with the variable name, or an array of variables. Multiple parameters are allowed.
Example:
<?php
$firstname = "Albert";
$lastname = "Smyth";
$age = "56";
$result = compact("firstname", "lastname", "age");
print_r($result);
?>
Output:
| Previous | Home | Next |