A variable to take on the name the name of array keys
I need to get a variable to开发者_运维技巧 be named whatever this array key is, in this case, the array key is only 1 word, so it would be something like; theme, entry or date.
$a = implode(array_keys($_GET));
In this case, I can get $a to equal theme, entry or date, but how can I get the variable to be called $theme $entry or $date?
Try
extract($_GET);
http://php.net/manual/en/function.extract.php
a simple way to do it
foreach ($_GET as $key => $value) {
$$key = $value;
}
now if you had $_GET['id']
you can use
echo $id;
精彩评论