Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/284.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/loops/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/symfony/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 循环遍历while语句_Php_Loops_While Loop - Fatal编程技术网

Php 循环遍历while语句

Php 循环遍历while语句,php,loops,while-loop,Php,Loops,While Loop,我在一个数组中存储了一系列mysql查询结果资源 例如数组([0]=>资源[1]=>资源…等) 此代码检索数组中的第一个资源: $third_count = "0"; while ($user_result = mysql_fetch_array($user[$third_count])) { print_r($user_result); } $third_count = $third_count +1; 我只是被困在试图找到一个if语句,它将在数组中循环 比如:while($third\u

我在一个数组中存储了一系列mysql查询结果资源

例如数组([0]=>资源[1]=>资源…等)

此代码检索数组中的第一个资源:

$third_count = "0";
while ($user_result = mysql_fetch_array($user[$third_count])) {
print_r($user_result);
}
$third_count = $third_count +1;
我只是被困在试图找到一个if语句,它将在数组中循环

比如:while($third\u count=<$second\u count)是我需要的,但它似乎不起作用

其中$second count是数组中的元素数


谢谢你的指点

您要做的是使用循环遍历结果资源数组。那么计数就无关紧要了

foreach($resourcearr as $res) {
    while ($user_result = mysql_fetch_array($res)) {
        print_r($user_result);
    }
}

啊,我自己修的。把=<位转错了方向。看起来不对劲!我曾想过这样做,但我不确定结果资源(相对于普通数组)是否可以这样使用。它是一个普通数组。它只是一系列资源。