开发者

Simple foreach loop

I have this code:

$summize = new summize;
$search = $summize->search(开发者_如何学运维'#test');

$text = $search->results[0]->text;

$text stores the result, but only the first result of the array.

How ca a write a loop to go through all the values and output through say echo...


You can try foreach:

foreach ($search->results as $result) { echo $result->text; }


This code can help you:

$n=0;
while ($text = $search->results[$n]){
   echo "[$text->text]<br>";
   $n++;
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜