In PHP, how can one convert multiple arrays into a multidimensional array?
To convert multiple arrays into a multidimensional array in PHP, you can use the array_merge function to merge the arrays together. This will create a new array where each original array becomes a sub-array within the multidimensional array.
$array1 = [1, 2, 3];
$array2 = ['a', 'b', 'c'];
$array3 = ['x', 'y', 'z'];
$multiArray = [$array1, $array2, $array3];
print_r($multiArray);
Keywords
Related Questions
- In PHP, what is the advantage of using mysqli_fetch_assoc() over fetch_row() when fetching data from a database?
- How can the glob function be effectively used in PHP to iterate through files in a directory?
- How can PHP developers prevent data loss when multiple users are uploading files simultaneously?