how to assign key for array element in 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 push key value
<?php
$image[0] = $image[0].','.$filename;
?>