我很困惑为什么第一个结果 0 没有被迭代。有人可以解释为什么并告诉我需要做什么来显示[0]的结果吗?
Here is my Array:
array(3) { [0]=> string(3) "390" [1]=> string(3) "377" [2]=> string(3) "382" }
请注意 [0] 结果未通过 foreach 显示。最后两个 [1] 和 [2] 显示得很好。
你可以在这里看到这个结果: http ://www.rotaryswing.com/swingviewer/videos.php
<?php
//iterate through video IDS in our DB
foreach ($pieces as $key => $v) {
$sql ="SELECT id, video_name, link, phase FROM videos WHERE id=?";
if ($stmt = $mysqli->prepare($sql)) {
$stmt->bind_param("i", $v);
if ($stmt->execute()) {
$stmt->bind_result($id, $vid_name, $vid_link, $phase);
while ($stmt->fetch()) {
echo "<a style=\"font-size: 14px;\" href='http://www.rotaryswing.com/golf- instruction/video/rst-index.php?cat=$phase&subcat=Rotary%20Swing%20Tour&video=$id&id=$vid_link&name=$vid_name' target=\"blank\">$vid_name</a><br>";
}
}
else {
trigger_error("SQL query failed: " . $stmt->error, E_USER_ERROR);
}
}
}
?>
当我只回声时,它回声很好。
<?php echo $pieces[0] . "<br/>";?>
<?php echo $pieces[1] . "<br/>";?>
<?php echo $pieces[2] . "<br/>";?>