Monday, 12 April 2021

PHP compact

Create an array from variables and their values:

 $firstname = "Peter";

$lastname = "Griffin";

$age = "41";


$result = compact("firstname", "lastname", "age");


print_r($result);


Array ( [firstname] => Peter [lastname] => Griffin [age] => 41 )

No comments:

Post a Comment