English 中文(简体)
多维阵列的第二个方面从未达到,为什么?
原标题:The second dimension in multi-dimension array never reached, why?
  • 时间:2012-01-12 19:06:58
  •  标签:
  • php

请允许我解释一下,这一法典为什么不起作用:

<?php
for($i = 0; $i < 3; $i++) {
    for($j = 0; $j < 3; $j++) {
        $arr[$i][$j] = $i.$j; 
    }
 }

 foreach ($arr as $key => $value) {
    foreach ($value as $key2 => $value2){ // line 8 = error
         echo  $key." ".$key2."<br />";
     }
 }
?>

我发现这一错误:

警告:在C:wampwwwscriptindex.中,为 foreach()提供了无效的论点。 第8行

我根本不能理解为什么我得出这一错误。 应以两者的数值启动阵列。 RIght?

问题回答

我已尝试过这一试验,并将之作为与西经共体项目2.2的产出:

0 0
0 1
0 2
1 0
1 1
1 2
2 0
2 1
2 2

你们是否使用最近的amp? 尝试下载和安装新版本。





相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签