数组中[0]的含义($ productByCode [0] [" code"]

时间:2017-06-15 12:02:08

标签: php

我试图理解在线教程中的一些代码,并偶然发现了一些我不理解的内容。

$productByCode = $db_handle->runQuery("SELECT * FROM tblproduct WHERE code='" . $_POST["code"] . "'");

$itemArray = array($productByCode[0]["code"]=>array('name'=>$productByCode[0]["name"], 
                                                    'code'=>$productByCode[0]["code"], 
                                                    'price'=>$productByCode[0]["price"]));

[0]中的array($productByCode[0]["code"]是什么意思?

1 个答案:

答案 0 :(得分:0)

它通常意味着第一个元素。索引从0开始。所以[0]表示该数组中的第一个元素。我看到你正在获取DB记录集。这意味着你的第一排。