how to create an array with key php code example
Example 1: php variables as keys in arrays
$id = 1;
$age = 2;
$sort = "id"; // or "age";
$Key = $$sort;
$arr = array($Key => 'string');
print_r($arr);
Example 2: php array
$array = ['cheese', 'ham', 'potato'];
var_dump($array);