A PHP array of US state abbreviations and their corresponding territory code, including the leading zero.
Efficiently get a Random Array Element
An efficient way to show a random value from an array, using PHP’s array_rand() functions.
Standardize string to a strict format
Some file systems don’t accept spaces and make no difference between lowercase and uppercase characters. Also when doing mod_rewrite and you would like to standardize an URL, it’s a good idea (although not always necessary) to remove white spaces and other special characters. This PHP function standardizes a string using a series of function calls and regular expressions.
Extract the file extension using PHP
Extract the file extension of the specified file name / file path using the pathinfo() function.
Find Twin Primes
Find the first 1000 twin prime numbers in Java using an isPrime function for the primality check and a value comparison between the prime numbers.
FTP Connection Using PHP
This sample code shows you how to connect to a remote FTP server using PHP’s built-in functions, retrieve a text file and save it on the current server.
Convert RGB Color Value To Hexadecimal
A simple way to convert RGB colors to their hexadecimal values by using the dechex() function.
Extended Euclidean Algorithm Function
A function for finding the modular multiplicative inverse, based on an extended version of the Euclidean algorithm.
Round Floating Point Numbers
Custom floating point rounding based on three functions that allow you to round to a certain precision, round up and round down.
Convert Pixels To Centimeters
A Ruby function that can be easily adapted to work with any language, because it uses a simple division and multiplication to calculate the number of centimeters in the given pixel size.