私は製品リストを持っています.4つのアイテムをランダムに表示する必要があります.
<?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']];
}
?>
ご覧のとおり、リストから4つのアイテムのみをランダムに表示する必要があるリストがあります。
前もって感謝します!