小说伪造详情页面 代码优化
This commit is contained in:
@@ -202,17 +202,16 @@
|
||||
{php}
|
||||
$arrRandomForgeNovels = [];
|
||||
if (isset($arrNovel['n_forge_novel']) && is_array($arrNovel['n_forge_novel'])) {
|
||||
$forgeNovels = $arrNovel['n_forge_novel'];
|
||||
if (count($forgeNovels) > 10) {
|
||||
$randomKeys = array_rand($forgeNovels, 10);
|
||||
$arrRandomForgeNovels = array_intersect_key($forgeNovels, array_flip($randomKeys));
|
||||
} else {
|
||||
$arrRandomForgeNovels = $forgeNovels;
|
||||
shuffle($arrRandomForgeNovels);
|
||||
$forgeNovels = $arrNovel['n_forge_novel'];
|
||||
$count = count($forgeNovels);
|
||||
if ($count > 0) {
|
||||
$randomKeys = array_rand($forgeNovels, min(10, $count));
|
||||
foreach ((array) $randomKeys as $key) {
|
||||
$arrRandomForgeNovels[] = $forgeNovels[$key];
|
||||
}
|
||||
}
|
||||
}
|
||||
$arrRandomForgeNovels = array_values($arrRandomForgeNovels);
|
||||
}
|
||||
{/php}
|
||||
{/php}
|
||||
|
||||
|
||||
{volist name='arrRandomForgeNovels' id='ForgeNovel' key="key"}
|
||||
|
||||
Reference in New Issue
Block a user