I’m sick of forgetting all those useful little bits of PHP, so I’m putting them here…


Get the current domain
echo $_SERVER['SERVER_NAME'];


Get the current page
echo $_SERVER['REQUEST_URI'];


Create an array from a text file on the server, exploding it on every new line
$textfile = file('./textfile.txt', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
$words = array_map('rtrim',$textfile);