我有产品列表,从女巫那里我需要随机显示四个项目。
<?php
// my product list
function productlistX {
$array = array(
$product {$name = 'product name', $link = 'product link', $img = "product image"};
$product {$name = 'product name', $link = 'product link', $img = "product image"};
$product {$name = 'product name', $link = 'product link', $img = "product image"};
$product {$name = 'product name', $link = 'product link', $img = "product image"};
$product {$name = 'product name', $link = 'product link', $img = "product image"};
$product {$name = 'product name', $link = 'product link', $img = "product image"};
$product {$name = 'product name', $link = 'product link', $img = "product image"};
$product {$name = 'product name', $link = 'product link', $img = "product image"};
$product {$name = 'product name', $link = 'product link', $img = "product image"};
$product {$name = 'product name', $link = 'product link', $img = "product image"};
$product {$name = 'product name', $link = 'product link', $img = "product image"};
$product {$name = 'product name', $link = 'product link', $img = "product image"};
$product {$name = 'product name', $link = 'product link', $img = "product image"};
$product {$name = 'product name', $link = 'product link', $img = "product image"};
$product {$name = 'product name', $link = 'product link', $img = "product image"};
)
// need to display 4 random products from the array above
foreach {
echo "<li>".$name . $link . $img . "</li>"
}
}
// display these random products in my ajax tab (products.php?order=mytab)
$data['mytab'] = $productlistX;
if (isset($data[$_GET['order']])) {
echo $data[$_GET['order']];
}
?>
如您所见,我的列表蚂蚁只需要随机显示列表中的四个项目。
提前致谢!