I often see or have to convert a bunch of variables into an array like this:
$array = array("description"=>$description, "title"=>$title, "page"=>$page, "author"=>$author);
Basically, all array keys match the name of the variable that is being passed in. Is there a way to reference a variable name so that it can be passed into the array like so:
$array[varName($description)] = $description;
No comments:
Post a Comment