Skip to content

Instantly share code, notes, and snippets.

@klhall1987
Last active October 9, 2015 13:37
Show Gist options
  • Save klhall1987/b79cb4646f929c015aec to your computer and use it in GitHub Desktop.
Save klhall1987/b79cb4646f929c015aec to your computer and use it in GitHub Desktop.
Compact Example
<?php
//Describes phone
$brand = "HTC";
$model = "One M8";
$os = "Android";
//Creates the phone array using the variables above as key value pairs.
$phone = compact("brand", "model" , "os");
//outputs the following array: Array ( [brand] => HTC [model] => One M8 [os] => Android )
print_r($phone);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment