We are learningFor ordinary computer enthusiasts, PHP may be an unfamiliar name. Friends who pay more attention to the Internet, especially those who pay attention to website construction technology, may have heard of PHP. PHP is a simple yet powerful programming language designed for dynamically creating HTML content.
PHP itself is a simple yet powerful language. The PHP language has core features such as powerful string and array processing capabilities, and has greatly improved support for object-oriented programming (PHP5 and above). By using standard and optional extension modules, PHP applications can connect to more than a dozen databases such as MySQL or Oracle, draw, create PDF files, and create and parse XML files. You can also use C language to write your own PHP extension module. For example, provide a PHP interface function in an existing code base. You can also run PHP under Windows, use COM to control other Windows applications such as Word and Excel, or use ODBC to connect to a database. The above is a brief introduction to PHP. Let's take a look at the relevant knowledge of PHP two-dimensional array assignment.
In ASP
<ol class="dp-xml"><li class="alt"><span><span>dim NamAre() //定义数组 </span></span></li></ol>
via SQL The number of records obtained from the statement query is total.
Assign value through while loop<ol class="dp-xml"><li class="alt"><span><span>redim NamAre(total,2) //重新定义数组,其中total为查询得到的记录数 </span></span></li></ol>
<ol class="dp-xml"> <li class="alt"><span><span>NamAre(i,1)=rolename </span></span></li> <li class=""><span>NamAre(i,2)=Area </span></li> </ol>
<ol class="dp-xml"> <li class="alt"><span><span>$</span><span class="attribute"><font color="#ff0000">data_array</font></span><span>=array($total,2);//其中$datarows为查询得到的记录数 </span></span></li> <li class="alt"><span><span>$data_array[$i][2]=$Area;//提示错误:Cannot use a scalar value as an array </span></span></li> </ol>
http://www.bkjia.com/PHPjc/446359.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/446359.htmlTechArticle
<ol class="dp-xml"> <li class="alt"><span><span>$</span><span class="attribute"><font color="#ff0000">i</font></span><span>=</span><span class="attribute-value"><font color="#0000ff">0</font></span><span>; </span></span></li> <li class="alt"><span><span> while($</span><span class="attribute"><font color="#ff0000">result</font></span><span>=$db-</span><span class="tag"><strong><font color="#006699">></font></strong></span><span>fetch_array($query)) </span></span></li> <li class="alt"><span><span> { $</span><span class="attribute"><font color="#ff0000">Area</font></span><span>=$result["Area"]; </span></span></li> <li class="alt"><span><span> $data_array[$i][2]=$Area; //出错! </span></span></li> <li class="alt"><span><span>$</span><span class="attribute"><font color="#ff0000">i</font></span><span>=$i+1; </span></span></li> <li class="alt"><span><span>} </span></span></li> </ol>