Find a php code
$ List = explode ("\ n", str_replace ("\ r", "", $ name); foreach ($ list as $ key => $ value) {$ arr = explode ('=', $ value); $ name_types [$ arr [0] = $ arr [1];} assume that the resulting numbers are $ key and $ value1 Zhang San 2 Li Si 3 Wang Bin 4 Li Mei 5 Guan Jing.
Now the problem is that I want to create a student page. for everyone, I want to write a file at a time and the result is:
Action = 1
Action = 2
Action = 3
The number next to this type of action is the above $ key.
How to write this code in the PHP file? Which of the following is incorrect?
If ($ _ GET ['action'] = '$ key '{
.....
}
Reply to discussion (solution)
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];}