Find a php code

Source: Internet
Author: User
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];}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.