Printing Random Array Elements in PHP and Javascript

Non-dynamic tag cloud?

 <script language=”JavaScript” type=”text/javascript”>
                                var mytags = new Array(
                                “histories”,”names”,
                                “land”,”lists”,”free”
                                );
                                var randomseed=Math.floor(Math.random()*8)
                                for(i=0;i<mytags.length;i++){
                                        var randomnumber=Math.floor(Math.random()*141)
                                        randomnumber=randomnumber+40;
                                        if(randomnumber%randomseed!=0){
                                        document.write(“<a style=’font-size:”+ randomnumber +”%;’>”+ mytags[i] + “</a> “);
                                        }
                                }
                        </script>

<?php
$input = array(“histories”,”names”,
                                “land”,”lists”,”free”);
$rand_keys = array_rand($input, 30);
for($i;$i<30;$i++){
$randomnumber=rand(40,181);
echo “<a style=’font-size:”.$randomnumber.”%;’>”.$input[$rand_keys[$i]] . “</a>\n”;
}
?>

Leave a Reply

  • (will not be published)

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>