Home>Article>Backend Development> Detailed explanation of php array_combine() function example

Detailed explanation of php array_combine() function example

王林
王林 Original
2020-08-12 17:16:54 2306browse

Detailed explanation of php array_combine() function example

array_combine() function creates a new array by merging two arrays, where the elements of one array are key names and the elements of the other array are key values.

This function returns the merged array. If the two arrays have different numbers of elements, return FALSE.

(Recommended tutorial:php graphic tutorial)

Note: The number of elements in the key name array and the key value array must be the same!

Syntax:

array_combine(keys,values);

Parameters:

  • keys Required. Specifies the key name of the array.

  • #values Required. Specifies the key value of the array.

(Learning video recommendation:php video tutorial)

Example:

Output result:

Array ( [Peter] => 35 [Ben] => 37 [Joe] => 43 )

The above is the detailed content of Detailed explanation of php array_combine() function example. For more information, please follow other related articles on the PHP Chinese website!

php
Statement:
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