Home  >  Article  >  Backend Development  >  How to implement random jump URL in php

How to implement random jump URL in php

L
LOriginal
2020-06-01 14:51:188514browse

How to implement random jump URL in php

php random jump URL method

1. First use array to store all urls in an array or store them in In the database;

2. Then use array_rand to randomly obtain an array subscript;

3. Finally, use the header combined with the randomly obtained URL to jump to the page

<?php
$arr = array(
    &#39;https://www.baidu.com&#39;,
    &#39;https://cn.bing.com/&#39;,
    &#39;http://google.com/&#39;
);
$key = array_rand($arr, 1);
//输出随机内容
// echo $arr[$key];
header(&#39;Location: &#39; . $arr[$key]);
exit;

For more PHP related knowledge, please visit PHP Chinese website!

The above is the detailed content of How to implement random jump URL in php. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn