PHP one-dimensional array to two-dimensional array method example code

怪我咯
Release: 2023-03-13 15:42:01
Original
2691 people have browsed it

You can use subscript variables in the program, which means that the entirety of these variables is an array, and the data type of each variable in the array is the same. When each element in the array has only one subscript, such an array is called One-dimensional array.

One-dimensional array is a single-structured array composed of numbers arranged in a simple sorting structure. One-dimensional arrays are the most basic arrays in computer programs. Two-dimensional and multidimensional arrays can be regarded as generated by multiple superpositions of one-dimensional arrays.

Two-dimensional array is essentially an array with an array as an array element, that is, an "array of arrays".

This article mainly introduces the method of converting one-dimensional array to two-dimensional array in PHP. It analyzes the skills of operating arrays in PHP with examples. It has certain For reference value, friends in need can refer to

This article describes the method of converting a one-dimensional array to a two-dimensional array in PHP. Share it with everyone for your reference. The specific implementation method is as follows:

<?php 
$asr[1] = array("a","b","c","d");
$asr[2] = array("a","b","c","d");
$asr[3] = array("a","b","c","d");
$newarray = array();
foreach($asr as $a)
{
$newarray[] = $a;
}
print_r($newarray);
?>
Copy after login

The above is the detailed content of PHP one-dimensional array to two-dimensional array method example code. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template