Random links

Started on the old forum in May 2011 · view the original in the archive · old links redirect here

7 replies · 735 views · started 15 years ago · 1 min read

4 participants
poporopop25 Developer · 60 posts #1
<?php 
$cats=array( 
"turn the beat on-beat production.mp3"=>"turn the beat on-beat production", 
"the final destiny-virus.mp3"=>"the final destiny-virus", 
"the access of trance-dj crack.mp3"=>"the access of trance-dj crack", 
"star wars theme-plan @ work.mp3"=>"star wars theme-plan @ work", 
"secret desire-steven gore.mp3"=>"secret desire-steven gore", 
"paradise-t.o..mp3"=>"paradise-t.o.", 
"out of sight-copycat.mp3"=>"out of sight-copycat", 
"my definition of trance-lord razor.mp3"=>"my definition of trance-lord razor", 
"magic melody-groove solution.mp3"=>"magic melody-groove solution", 
"god danced-dj taylor & flow.mp3"=>"god danced-dj taylor & flow", 
); 
shuffle($cats);
foreach($cats as $key=>$cat){ 
$lnk="<b>» </b><a href='file.php?file=Club/$key&start=1'>$cat</a><br/>"; 
echo $lnk; 
} 
?>

I just got incorrect link file.php?file=Club/0&start=1, file.php?file=Club/1&start=1 it should be like this file.php?file=Club/turn the beat on-beat production.mp3&start=1

PLEASE HELP!!!

mayurss786 Developer · 137 posts #2

You can also use this

<?php 
 
 
$urls = array("http://hotwapi.com/?id=mirchiwapin" ,"http://hotwapi.com/?id=mirchiwapin" ,"http://hotwapi.com/?id=mirchiwapin","http://hotwapi.com/?id=mirchiwapin" ,"http://hotwapi.com/?id=mirchiwapin" ,"http://hotwapi.com/?id=mirchiwapin" ,"http://hotwapi.com/?id=mirchiwapin", "http://hotwapi.com/?id=mirchiwapin", "http://hotwapi.com/?id=mirchiwapin", "http://hotwapi.com/?id=mirchiwapin" ); 
 
$text = array("Hungama" ,"Instant Khichadi" ,"Mobile Dhamaka" ,"Papad Pol" ,"About iPill" ,"Extra Ordinary Humans" ,"Jalwa" ,"American Samose" ,"Sms Dukan" ,"Dekho Aeroplane"); 
        srand(time()); 
 
//set the number in (rand()%4); for however many links there are 
        $random = (rand()%10); 
echo ("<a href = \"$urls[$random]\">$text[$random]</a>"); 
?>

this is demo MirchiWap.IN:: Free mobile downloads mp3 amr midi wav ringtones themes wallpaper java game sis 3gp avi videos check bottom of page

arnage Lead · 811 posts #4

Keep it simple.

function randomstuff() {
$lines = array();
$lines[] = 'Some Text';
$lines[] = 'Some Text';
$lines[] = 'Some Text';
$lines[] = '<a href="http://link.tld/">Name</a>';
$lines[] = '<a href="http://link.tld/">Name</a>';
$lines[] = '<a href="http://link.tld/">Name</a>';
$number = count($lines) - 1;
srand ((double) microtime() * 1000000);
$random = rand(0, $number);
return $randomlines = $lines[$random];
}
echo randomstuff();
<!DOCTYPE html PUBLIC "-//***WAPFORUM**.**RS***
mayurss786 Developer · 137 posts #5

very good code thnx

arnage wrote: Keep it simple.

function randomstuff() {
$lines = array();
$lines[] = 'Some Text';
$lines[] = 'Some Text';
$lines[] = 'Some Text';
$lines[] = '<a onclick="_gaq.push(['_trackEvent', 'Outgoing', 'link.tld', '/']);" rel="nofollow" href="http://link.tld/">Name</a>';
$lines[] = '<a onclick="_gaq.push(['_trackEvent', 'Outgoing', 'link.tld', '/']);" rel="nofollow" href="http://link.tld/">Name</a>';
$lines[] = '<a onclick="_gaq.push(['_trackEvent', 'Outgoing', 'link.tld', '/']);" rel="nofollow" href="http://link.tld/">Name</a>';
$number = count($lines) - 1;
srand ((double) microtime() * 1000000);
$random = rand(0, $number);
return $randomlines = $lines[$random];
}
echo randomstuff();
poporopop25 Developer · 60 posts #7

antony2kx wrote:

$ar = array('text1'=>'link.mp3', 'text2'=>'link2.mp3', 'text3'=>'link3.php');
$link = array();
foreach($ar as $key=>$value)
{

$link[] = '<a onclick="_gaq.push(['_trackEvent', 'Outgoing', '', '']);" rel="nofollow" href="http://'.$value.'">'.$key.'</a>';

}//get all links into array


get individual link

echo $link[rand(count($link)-1)];

i just got error.....

Added after 5 minutes:

i just want an output that name is not including the file extension while url has the file extension. and it will shuffle and print only 5 links... ex. 1. going crazy fun on the floor

this is not random ads that you have to put diff links in diff name... i have to put correctly the url on correct name... im just having a problem in random function... thanks for the post....

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close