1
我想隨機化x(取決於$ max)結果。現在,該列表按照代碼指向的XML文件($ string)的順序呈現。有任何想法嗎?隨機化SimpleXML對象結果
<?php
$xml_feed = simplexml_load_string($string);
global $xml_global_f;
$xml_global_f = $xml_feed;
foreach($xml_global_f->reviewDetails->reviewDetail as $val)
{
if ($count < $max)
{
?>
<li><p><i class="fa fa-comment-o fa-flip-horizontal fa-lg"></i>
<span itemprop="review" itemscope itemtype="http://schema.org/Review">
<span itemprop="name"><strong><?php
echo $val->user; ?></strong></span><br /><br>
<span itemprop="reviewBody"> <?php
echo $val->text; ?></span>
<span content="<?php
echo $val->user; ?>" itemprop="author"></span><span content="<?php
echo $global_fcs_bn; ?>" itemprop="itemReviewed"></span></p></li>
<?php
}
$count++;
}
?>
感謝巴勃羅!這有幫助! – Gerard