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

How to create a multidimensional array in php

王林
王林Original
2020-08-24 16:44:503065browse

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);
?>

(Learning video recommendation: php video tutorial)

Running results:

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

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!

Statement:
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