If i have the following array
$arr = [4,7,8];
$var = 3
and need the following result using PHP functions and operators or most efficient way for large arrays.
$result = [
[3,4],
[3,7],
[3,8]
]
If i have the following array
$arr = [4,7,8];
$var = 3
and need the following result using PHP functions and operators or most efficient way for large arrays.
$result = [
[3,4],
[3,7],
[3,8]
]
My way is the following
$col1 = array_pad($vals,sizeof($arr),$var); // [3,3,3]
$result = array_map(null,$col1,$arr);