array_combine function:
The array_combine function combines two arrays. It takes two parameters first array as index values and second array as values.
Code:
<?php
$name_staring_values=array("T","R","A","M");
$names=array("Tahreem","Rizwan","Anwar","Misbah");
print_r(array_combine($name_staring_values,$names));
?>
Output:
Array ( [T] => Tahreem [R] => Rizwan [A] => Anwar [M] => Misbah )
Explanation:
The above code takes the values in the array $name_staring_values (representing the keys/index values) and combines them with the values in $names (representing the strings).
On line 4 then we have passed both arrays to array_combine function of php. print_r is like echo or print that print something on screen like print_r print entire array on screen by their index.