Home > Backend Development > PHP Tutorial > PHP tips: Exchange the keys and values ​​of the array to form a new array, find the value and get the key_PHP tutorial

PHP tips: Exchange the keys and values ​​of the array to form a new array, find the value and get the key_PHP tutorial

WBOY
Release: 2016-07-21 15:29:38
Original
995 people have browsed it

Copy code The code is as follows:

$cityname = array_flip($city_DB[name]); //Exchange the keys and values ​​of the array A new array is formed
$city_name = array_search($city_id,$cityname,true); //Find the value and get the key

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/323421.htmlTechArticleCopy the code The code is as follows: $cityname = array_flip($city_DB[name]); //Add the keys of the array to The value exchange forms a new array $city_name = array_search($city_id,$cityname,true); //The search value is...
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