array('a','d','er'),     "历史图书"="/> array('a','d','er'),     "历史图书"=">

PHP二维数组,该如何解决

WBOY
Release: 2016-06-13 12:53:49
Original
946 people have browsed it

PHP二维数组

<br />
<br />
<br />
$str = array (<br />
            "网络编程图书"=>array('a','d','er'),<br />
	    "历史图书"=>array('boko','fd','popo'),<br />
	    "文学图书"=>array('fd','fd','fd'),<br />
	);	<br />
	<br />
	  echo $str[0][2];<br />
<br />
<br />
Copy after login


为什么不显示


------解决方案--------------------
当然不显示!没有下标0,如何显示?
------解决方案--------------------
因为你原本是0的位置被‘网络编程图书’给替代了
echo $str[‘网络编程图书’][2]
------解决方案--------------------
你这个二维数组 ,最外面的时候关联数组 下标是字符窜 不是数字
------解决方案--------------------
你可以把代码改成
$str = array (
        array('a','d','er'),//网络编程图书
        array('boko','fd','popo'),//历史图书
        array('fd','fd','fd'),//文学图书
    );    
     
      echo $str[0][2];
这样就显示了
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