[英]Trouble displaying results of foreach loop
I am trying to get the results of an array and output it in this format: 我试图获取数组的结果并以这种格式输出:
Author: Kate 作者:凯特
Text: This is the text for result 1 文字:这是结果1的文字
Author: Jen Text: This is the text for result 2 作者:仁文本:这是结果2的文本
The results return several records and I need to use my first ever FOREACH loop to go through and display them all, but I am having a hard time getting the results to format correctly. 结果返回几条记录,我需要使用我的第一个FOREACH循环来遍历并显示所有记录,但是我很难使结果正确格式化。 I've looked at many website and tried many things and I know the below code is very wrong. 我浏览了许多网站并尝试了许多事情,并且我知道以下代码非常错误。 Can someone help me figure out what is right? 有人可以帮我弄清楚什么是对的吗?
<?php
foreach ($results){
echo "results->display_name;"<br>"echo "$results->text";
}
?>
foreach ($results as $result) {
echo $result->display_name . "<br>" . $result->text;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.