PHP array_combine() function it returns a new array by merging two other arrays, where the first array forms the keys, and the other array forms values for a new array.
Syntax: array_combine(array1,array2)
Parameters Description:
array1 : Required. An array, specifying the keys
array2 : Required. An array specifying the values
Note : Both parameters must have equal number of elements.
Example:
Syntax: array_combine(array1,array2)
Parameters Description:
array1 : Required. An array, specifying the keys
array2 : Required. An array specifying the values
Note : Both parameters must have equal number of elements.
Example:
<?php $keyarr = array("a","b","c","d"); $daysarr = array( "Sunday","Monday","Tuesday","Wednesday"); print_r( array_combine($keyarr,$daysarr) ); ?>
Output:
Array ( [a] => Sunday [b] => Monday [c] => Tuesday [d] => Wednesday )
0 comments:
Post a Comment