开发者

Simple foreach loop

开发者 https://www.devze.com 2022-12-15 03:19 出处:网络
I have this code: $summize = new summize; $search = $summize->search(开发者_如何学运维\'#test\');

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

精彩评论

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