Home  >  Article  >  Backend Development  >  求一段php代码

求一段php代码

WBOY
WBOYOriginal
2016-06-20 12:48:09961browse

$list = explode ("\n", str_replace ("\r", "", $name));foreach($list as $key=>$value){	$arr=explode('=',$value);	$name_types[$arr[0]]=$arr[1];	}假设得出的数字是$key和$value1张三 2李四 3王斌 4李梅 5关静


现在的问题是 我想创建个同学页面,关于每个人的,想一次写个 大概是展示结果是:
action=1
action=2
action=3
这种类型的  action后面的数字是上面的$key

在php文件里 这段代码怎么写?下列不正确啊?
if($_GET['action']=='$key'{
.....
}


回复讨论(解决方案)

if($_GET['action']==$key){
.....
}

$key = $_GET['action'];if(isset($name_types[$key])) {.....}

$list = explode ("\n", str_replace ("\r", "", $name));foreach($list as $key=>$value){    $arr=explode('=',$value);    $name_types[$arr[0]]=$arr[1];   }$action = isset($_GET['action'])? $_GET['action'] : '';if(isset($name_types[$action])){	echo $name_types[$action];}

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn