Home  >  Article  >  Backend Development  >  动态数组是如何创建的

动态数组是如何创建的

WBOY
WBOYOriginal
2016-06-13 13:37:421036browse

动态数组是怎么创建的?

PHP code
<!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

-->
$theTBHead = array();//这个不是很理解,没有指定长度能添加数据吗?
while($row2 = mysql_fetch_array($sql2))
{
    //这里希望将$row2["nChinese"]字段依次存储到$theTBHead的每个元素中,
    //而且希望元素脚标是递增编号的(0,1,2,3...这样的脚标),应该怎么写呀?
}




------解决方案--------------------
$theTBHead = array();

于是 $theTBHead 是一个空的数组

php 的数组并不是数学意义上的数组,只是使用了这个名字
他实际上是一个结构、一个链表
------解决方案--------------------
array_push($theTBHead,$row2["nChinese"]);
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