Randomly sort an array using PHP’s shuffle() function

If you ever need to randomise a PHP array, and want to do it in one line, use the shuffle() function. It’s especially useful when you just want to draw one array member randomly, like in a lottery or something.

$values = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); 
shuffle($values); //randomise the array members
echo array_pop($values); //outputs a random number from $values

MySQL timestamp syntax quick reference

Quick code post with a really useful little function, all it does it return a MySQL timestamp value of ‘now’. It’s useful if you haven’t already committed the format to memory, which sadly I have already… but still, it’s good to have in a common function library.

function mysqlnow() {
    return date("Y-m-d H:i:s");