Home > Backend Development > PHP Problem > How to create a multidimensional array in php

How to create a multidimensional array in php

王林
Release: 2023-03-05 07:32:02
Original
3070 people have browsed it

How to create a multidimensional array in php

Multidimensional array

(Recommended tutorial: php graphic tutorial)

Multidimensional array contains one or more arrays array. In a multidimensional array, each element in the main array can also be an array, and each element in the subarray can also be an array.

Example:

<?php
$arr = array(
	"taobao"=>array(
		"淘宝"
	),
	"jingdong"=>array(
		"京东"
	),
	"meituan"=>array(
		"美团"
	)
);
print_r($arr);
?>
Copy after login

(Learning video recommendation: php video tutorial)

Running results:

Array ( [taobao] => Array ( [0] => 淘宝 ) [jingdong] => Array ( [0] => 京东 ) [meituan] => Array ( [0] => 美团 ) )
Copy after login

View Web page source code:

How to create a multidimensional array in php

The above is the detailed content of How to create a multidimensional array in php. 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