zoukankan      html  css  js  c++  java
  • PHP array_combine

    PHP5,PHP7

    1.函数的作用:使用两个长度相同的数组,组成一个新的数组;一个作为键值,一个作为键值对应的值;

    2.函数的参数:

      @parmas array  keys : 数组的值作为新数组的键值

      @params array values :  数组的值作为新数组的值

    3.要点:

      1)如果作为键值的数组keys中,有重复的值,组成新数组时,前一个会被后面相同的键值覆盖;  2)keys和values数组长度一样,不然会抛出错误;

    4.例子:

     1 <?php
     2 $value = [1,'lpl','abc123','123456'];
     3 $column = ['id','username','password','identity'];
     4 print_r(array_combine($column,$value));
     5 
     6 $matchmaker_boy = [
     7     'maker1'  => 'Jack',
     8     'maker2'  => 'Alexander',
     9     'maker3'  => 'Hunter'
    10 ];
    11 
    12 $matchmaker_girl = [
    13     'maker1'  => 'Lisa',
    14     'maker2'  => 'Trista',
    15     'maker3'  => 'Mabel'
    16 ];
    17 print_r(array_combine($matchmaker_boy,$matchmaker_girl));
    学习记录,方便复习
  • 相关阅读:
    python 爬虫 urllib模块 url编码处理
    python 爬虫 urllib模块 目录
    python 爬虫 urllib模块介绍
    python 爬虫 目录
    爬虫 介绍
    POJ 2533
    POJ 2531
    POJ 2524
    POJ 2505
    POJ 2521
  • 原文地址:https://www.cnblogs.com/jingjingdidunhe/p/6720806.html
Copyright © 2011-2022 走看看