Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/267.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/3/arrays/12.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 遍历字符串数组_Php_Arrays - Fatal编程技术网

Php 遍历字符串数组

Php 遍历字符串数组,php,arrays,Php,Arrays,对于我的代码: var_dump($POS) 给我: array (size=9) 0 => string 'technical' (length=9) 1 => string 'recruiter' (length=9) 2 => string 'experience' (length=10) 3 => string 'work' (length=4) 4 => string 'department' (length=10) 5 =>

对于我的代码:
var_dump($POS)

给我:

array (size=9)
  0 => string 'technical' (length=9)
  1 => string 'recruiter' (length=9)
  2 => string 'experience' (length=10)
  3 => string 'work' (length=4)
  4 => string 'department' (length=10)
  5 => string 'modern' (length=6)
  6 => string 'age' (length=3)
  7 => string 'profile' (length=7)
  8 => string 'prakhar' (length=7)
但是在遍历数组时,
$POS

        foreach($POS as $p)
        {
            echo "POS  :".$p."<br/>";
        }
更新

$POS
的循环正常,但问题在于

while ($row1 = @mysqli_fetch_array($selectTag))
                { 

}
因为我注意到,对于上面的
第一部分,虽然循环执行正确,但对于下一部分
$POS
,循环执行不正确

是否需要刷新/清除
$row1

此代码工作正常

尝试注释循环中的所有内容(只留下echo),数组中将包含所有值

您还应在代码开头添加:

error_reporting(E_ALL);
ini_set('display_errors','1');

(仅在测试时)并删除
@
mysqli_fetch_数组前面的
要显示所有错误

请提供再现问题的最小代码(带有数组定义的完整代码),在这两次调用之间是否运行任何函数?@AlmaDo:添加了code@MarcinNabiałek:不,我更新了代码
error_reporting(E_ALL);
ini_set('display_errors','1');