Generate array of different/unique random numbers in PHP

Sometime it is necessary to generate a list of different random numbers. A possible usage scenario therefore could be a raffle where the winners should be choosen by chance, but every single user shouldn’t get more than one prize.
So in the following snippet, I’ll show you how to generate a list of different randoms in PHP.

<?php
//Create an array of numbers from which the randoms
//should be choosen. (For raffle: the list of user id’s)
$array = range($minimum, $maximum);

//Initialize the random generator
srand ((double)microtime()*1000000);

//A for-loop which selects every run a different random number
for($x = 0; $x < $numberOfRandoms; $x++)
{
//Generate a random number
$i = rand(1, count($array))-1;

//Take the random number as index for the array
$result[] = $array[$i];

//The chosen number will be removed from the array
//so it […]

code-bude.net from now on in english

code-bude.net multilingual
I’ve planned for quite some time to blog in german and english. Therefore I read many articles about how to set up a multilingual wordpress blog. Although there are a lot of plugins for wordpress, which claim to be the best translation plugin ever, the most of them are more or less useless for me or don’t satisfy my requirements.
One importent criterion for me was that the plugin should work “hand in hand” with google. Sure, I’m not that epic seo professional, but I think I know the most basics. And a multiligual plugin, which save the texts from multi languages inside one post, under one url and only shows and hides these translations, is crap. Google will find one url, keywords and meta-tags only in one language, but texts for atleast two languages. That really isn’t […]