xxxxxxxxxx
/**
In Laravel, compact() is a PHP function that creates an array containing variables and their values.
It takes a variable number of arguments, each of which should be a string containing the name of a variable.
For example, if you have a variable $user with the value "John Doe" and a variable $age with the value 32,
you can use compact() to create an array like this:
**/
$user = "John Doe";
$age = 32;
$data = compact('user', 'age');
/**
After this code is executed,
$data will be an array with two elements, "user" => "John Doe" and "age" => 32.
You can then use this array to pass data to a view in Laravel,
or to access the variables in some other way.
**/
xxxxxxxxxx
return View::make('myviewfolder.myview', compact('view1','view2','view3'));
xxxxxxxxxx
// compact() is a php function that allows you to create an array with variable names and their values
<?php
$city = "San Francisco";
$state = "CA";
$event = "SIGGRAPH";
$location_vars = array("city", "state");
$result = compact("event", $location_vars);
print_r($result);
?>
The above example will output:
Array
(
[event] => SIGGRAPH
[city] => San Francisco
[state] => CA
)
// Like the post if you found it usefull and help other devs to find the good answer