Home > Backend Development > PHP Tutorial > 怎么把数组键名键值重置

怎么把数组键名键值重置

WBOY
Release: 2016-06-23 13:05:06
Original
3906 people have browsed it

array(6) {
  [0] => string(6) "品牌"
  [1] => string(6) "ABC"
  [2] => string(6) "颜色"
  [3] => string(20) "黄色|红色|黄色"
  [4] => string(6) "型号"
  [5] => string(18) "20FGH-111"
}

结果:

array(3) {
  ["品牌"] => string(6) "ABC"
  ["颜色"] => string(20) "黄色|红色|黄色"
  ["型号"] => string(18) "20FGH-111"
}

完全没有头绪啊,谢谢。


回复讨论(解决方案)

for($i=0; $i<count($原数组); $i+=2) {  $新数组[$原数组[$i]] = $原数组[$i+1];}
Copy after login

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