Home > Backend Development > PHP Tutorial > 关于多维数组的一个有关问题

关于多维数组的一个有关问题

WBOY
Release: 2016-06-13 12:05:41
Original
787 people have browsed it

关于多维数组的一个问题,

<?php<br /><br />	$class = [<br /><br />		"group1" => [<br />			["name"=>"zs","age"=>"10","sex"=>"nan"],<br />			["name"=>"ls","age"=>"11","sex"=>"nan"],<br />			["name"=>"ww","age"=>"12","sex"=>"nv"]<br />		],<br /><br />		 [<br />			["name"=>"zs","age"=>"10","sex"=>"nan"],<br />			["name"=>"ls","age"=>"11","sex"=>"nan"],<br />			["name"=>"ww","age"=>"12","sex"=>"nv"]<br />		],<br /><br />		 [<br />			["name"=>"zs","age"=>"10","sex"=>"nan"],<br />			["name"=>"ls","age"=>"11","sex"=>"nan"],<br />			["name"=>"ww","age"=>"12","sex"=>"nv"]<br />		]<br />	];<br />	echo '<pre class="brush:php;toolbar:false">';<br />	print_r( $class );<br />	echo '
Copy after login
';

?>

这个老是不对啊,求解。
Parse error: syntax error, unexpected '[' in D:\program files\wamp\www\text.php on line 3
------解决方案--------------------
你这个定义 的是什么?数组吗? 按你的思路应该这样定义。

$class =array(  "group1" => (
            ("name"=>"zs","age"=>"10","sex"=>"nan"),
            ("name"=>"ls","age"=>"11","sex"=>"nan"),
           ("name"=>"ww","age"=>"12","sex"=>"nv")
        ), 
         (
            ("name"=>"zs","age"=>"10","sex"=>"nan"),
            ("name"=>"ls","age"=>"11","sex"=>"nan"),
           ("name"=>"ww","age"=>"12","sex"=>"nv")
        ), 
        (
            ("name"=>"zs","age"=>"10","sex"=>"nan"),
            ("name"=>"ls","age"=>"11","sex"=>"nan"),
            ("name"=>"ww","age"=>"12","sex"=>"nv")
        )
    )) ;
     
------解决方案--------------------
你的代码要求 php >= 5.4

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