random plus regex ! im stuck

hello how are im new to php and im stuck i did research since this my first week and im stuck
i would like you guys to help me
i want to make a script that read from a txt file and select randomly a website and redirect to it but before check the head of the website for a word wich mean using regex if that word is there jump to another one and check again until it finds one without it and redirect to it
here is the onlything i did [php]<?php
$f_contents = file(“websites.txt”);
$line = $f_contents[rand(0, count($f_contents) - 1)];
header(“Location: $f_contents”);
?>[/php]

What would the point of this script be? What’s contained websites.txt? is it just urls? You need to first explode it on whatever the delimiter is. If each site is on a separate line, then it would be \r\n, after that, then you can get the random website by scrambling the array.

yes just urls

how are they separated?

ok i figure out the way to do it
[php]<?php
$urlList = file(‘x.txt’);
shuffle($urlList);
$url = array_pop($urlList);
$html = header("Location: $url ");
?>[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service