我試圖隨機重定向2 URL,但它不起作用。我的代碼<?php$urls=readStack();if(empty($urls)) { $urls = shuffle(array('https://domain1.com', 'https://domain2.com')); $url=array_pop($urls); storeStack($urls); header('Location:' .$url); ?>幫助如何解決這個問題?
1 回答

慕婉清6462132
TA貢獻1804條經驗 獲得超2個贊
我不知道是什么,但你可能想要這樣的東西readStack()storeStack()
$arr = array('https://domain1.com', 'https://domain2.com');
shuffle($arr); // This returns a boolean and the array is modified inside the function so just pass in the array
$url=array_pop($arr); // Pop the top most element from the array and store into $url
header("Location: $url");
僅該代碼就為您提供了來自這兩個的隨機URL
- 1 回答
- 0 關注
- 74 瀏覽
添加回答
舉報
0/150
提交
取消