未定义常数i的数组使用-假设为'i'

时间:2019-07-13 19:52:24

标签: php

无法通过for循环提取数组中的元素

echo($a . $row[0] . $b); --->Working
echo($a . $row[1 ...] . $b); --->Working

但是$row[i] --->无法正常工作

$query = $db->query("SELECT * FROM post WHERE id = '{$id}'")->fetch(PDO::FETCH_ASSOC);

$tag = $query['post_tag'];
$tag = explode( '/', $tag);
$deger = count($tag);

for($i=0;$i<$deger;$i++){

   $a = '  <li><a href="#">';
   $b = '</a></li>';
   echo($a . $row[i] . $b);
}
: Use of undefined constant i - assumed 'i' (this will throw an Error in a future version of PHP) inC:\xampp\htdocs\vizew\single-post.php on line 135
Notice: Undefined variable: row in

0 个答案:

没有答案