Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

laravel php what does compact

// 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
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #laravel #php #compact
ADD COMMENT
Topic
Name
5+7 =