求一段php代码

WBOY
Release: 2016-06-20 12:48:09
Original
962 people have browsed it

$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关静
Copy after login


现在的问题是 我想创建个同学页面,关于每个人的,想一次写个 大概是展示结果是:
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])) {.....}
Copy after login

$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];}
Copy after login

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template