开发者

A variable to take on the name the name of array keys

开发者 https://www.devze.com 2023-03-08 01:08 出处:网络
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.

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;
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号