PHP - array_combine
Trieda
Metóda - array_combine
(PHP 5, PHP 7)
Creates a single array from two arrays, first containing keys, second containing values.
Procedurálne
- function array_combine (array $keys) : array
Parametre
| Názov | Dátový typ | Predvolená hodnota | Popis |
|---|---|---|---|
| $keys | array | Array containing keys for items in the resulting array. Illegal will be converted to string. |
Mávratovej hodnoty
Vracia: array
If counts of array containing keys and array containing values is the same,
combined array is returned, false otherwise.
Príklady
<?php
$keys = array("key1", "key2", "key3");
$values = array("value1", "value2", "value3");
$combined = array_combine($keys, $values);
var_dump($combined);
Súvisiace manuály
- function array_merge (array $array1, array $...) : array
- function array_values (array $array) : array
