Solved

random link

Posted on 2007-03-21
4
185 Views
Last Modified: 2008-02-20
hello,
I would like to make something very simple for my site..
something like this

tutorial1 name link here
tutorial2 name link here
tutorial3 name link here

each time they refresh the same they change random places like this

tutorial2 name link here
tutorial3 name link here
tutorial1 name link here

can someone please help me do this?
0
Comment
Question by:Sabrin
  • 3
4 Comments
 
LVL 17

Expert Comment

by:HuyBD
Comment Utility
first, you add all to array

$arr=array("link1","link2","link3");
then
$link=$arr[rand(0,3)];


HuyBD;
0
 
LVL 17

Accepted Solution

by:
HuyBD earned 500 total points
Comment Utility
or

$arr=array("link1","link2","link3");
then
$link=$arr[rand(0,sizeof($arr))];

HuyBD;
0
 

Author Comment

by:Sabrin
Comment Utility
ohh im not that good at php could you please make it easier for me?
0
 
LVL 17

Expert Comment

by:HuyBD
Comment Utility
$arr=array("tutorial1 name link here","tutorial1 name link here","tutorial1 name link here");
$link=array_rand($arr,sizeof($arr));

for($i=0;$i<sizeof($link);$i++)
{
 echo $link[$i];
}

Hope this help

HuyBD;
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Both Easy and Powerful How easy is PHP? http://lmgtfy.com?q=how+easy+is+php (http://lmgtfy.com?q=how+easy+is+php)  Very easy.  It has been described as "a programming language even my grandmother can use." How powerful is PHP?  http://en.wikiped…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now