1 (edited by Tubby 2006-10-22 07:55)

Topic: Question!!

Ok atm iam trying to code something very simple. It may seem like a no-brainer to some of you php coders out there ;P

so far iam creating affliates.php

here it is

<div class="block">
<h2><span><?php echo 'Affliates'; ?></span></h2>
<div class="box" id="announce">
<div class="inbox">
<?php

$affliates = '<a href="#">'.pun_htmlspecialchars('Link 1').'<br /> <a href="#">'.pun_htmlspecialchars('Link 2').'</a></a>';

echo $affliates;

?>
</div>
</div>
</div>

Thats it so far. Iam placing this file in the "users" folder and including it through the main.tpl template.

Iam trying to shuffle these links. How would i go about doing this? Could i use the str_shuffle function?

Re: Question!!

I wouldn't use str_shuffle wink

Do you want to show both affiliates or only one?

3

Re: Question!!

i would like to show all affliates that there are on the page but shuffle them around.

Re: Question!!

Tubby wrote:

Iam trying to shuffle these links. How would i go about doing this? Could i use the str_shuffle function?

If I were you I'd do something like this:

$links = array
(
    array('http://...', 'label'),
    array('http://...', 'label'),
    ...
);

shuffle($links);
while(count($links) > 0)
{
    $cur_link = array_shift($links);
    echo '<a href="'.$cur_link[0].'">'.$cur_link[1].'</a>'."\n";
}
Looking for a certain modification for your forum? Please take a look here before posting.

Re: Question!!

Erm, pogenwurst, what did foreach() ever do to you? sad

<?php
$links = array(array('link', 'label'), array('link', 'label'));
shuffle($links);
foreach($links as $link_arr)
{
    echo '<a href="'.$link_arr[0].'">'.$link_arr[1].'</a>'."<br />\n"
}
?>

Too bad shuffle() messes up keys =/

6

Re: Question!!

wow thanks guys.....at the moment iam using pogenwursts cause it seems to be working just fine for me. As for elbekko thanks alot!

Re: Question!!

Tubby: maybe use this instead - the nonstupidity of elbekko's code + the prettiness of mine. smile

$links = array
(
    array('http://...', 'label'),
    array('http://...', 'label'),
    ...
);

shuffle($links);
foreach($links as $cur_link)
{
    echo '<a href="'.$cur_link[0].'">'.$cur_link[1].'</a>'."\n";
}

elbekko: Nothing, I just didn't know how to use it because I've never looked it up. big_smile

Looking for a certain modification for your forum? Please take a look here before posting.

8

Re: Question!!

how do you get pictures

Re: Question!!

mia wrote:

how do you get pictures

What?

Looking for a certain modification for your forum? Please take a look here before posting.