Home > Backend Development > PHP Tutorial > PHP method to convert array values ​​into keys, PHP array into keys_PHP tutorial

PHP method to convert array values ​​into keys, PHP array into keys_PHP tutorial

WBOY
Release: 2016-07-13 09:46:32
Original
934 people have browsed it

How PHP converts array values ​​into keys, PHP arrays into keys

The example in this article describes how PHP converts array values ​​into keys. Share it with everyone for your reference. The details are as follows:

function values2keys($arr, $value=1){
  $new = array();
  while (list($k,$v) = each($arr)){
    $v = trim($v);
    if ($v != ''){ 
      $new[$v] = $value;
    }
  }
  return $new;
}

Copy after login

I hope this article will be helpful to everyone’s PHP programming design.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1031486.htmlTechArticleHow to convert array values ​​into keys in php, Convert arrays into keys in php This article explains how to convert array values ​​in php Keying method. Share it with everyone for your reference. The details are as follows: function v...
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