Forum Moderators: coopster

Message Too Old, No Replies

String Jumbler

... if there is such a word ...

         

internetheaven

12:46 pm on Nov 29, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I have a string of adverts down the left hand side of my pages (about 10 of them). The insertion codes are in a string like this:

<a href='/url?www.example.com'><img src='/banner/1234.gif'></a> + <a href='/url?www.example1.com'><img src='/banner/1235.gif'></a> + <a href='/url?www.example2.com'><img src='/banner/1236.gif'></a>

using the + as the separator. Is there any coding that "jumbles" them up so that each page has them in a different order? If visitors are clicking through a few pages I'd like them to make different ads appear near the top on each page to maximise revenue.

I take it:

$a[ads] = jumble("+", $string);

won't work? ;)

Salsa

12:59 pm on Nov 29, 2004 (gmt 0)

10+ Year Member



You might put (or keep) the ads in an array, shuffle(the_array) each time you want to display them, then loop through the array to get the ads back out in the shuffled order.

pete_m

1:01 pm on Nov 29, 2004 (gmt 0)

10+ Year Member



This code will jumble the adverts string.

Assuming your un-jumbled adverts are in the string $ads :


$adsarray = explode(" + ", $ads);
shuffle($adsarray);
$jumbled_ads = implode(" + ", $adsarray);

(edit: beaten to it by Salsa!)

Salsa

1:12 pm on Nov 29, 2004 (gmt 0)

10+ Year Member



Ha! But given the ' + ', Pete, your specific implode/explode approach is surely the best way to get the ads in and out of the array.

internetheaven

10:46 pm on Nov 29, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks guys, I'll give that a shot ... fingers crossed ...