content top

Validate an Email Address

So, you’ve created a new user system but you need a way to see if an email address that someone has registered is genuine. This small script will do this by checking the email’s MX records. <?php function CheckEmail($email,$record = 'MX'){ //define a function list($user,$domain) = split('@',$email); //split up the email into two variables $user &...

Read More

Mode, Mean, Median, Range of an array

Any type of coding requires you to be a good mathematician as you are constantly using your code to solve math problems to make your program function correctly. Here is a way that you can use a single function to work out some simple math problems that you may need for your program to function. <?php function mmmr($array, $output = 'mean'){ if(!is_array($array)){ return FALSE; //failsafe ...

Read More

PHP Random String/Ticket Generator

This is a very basic script that generates a string 25 characters long using the characters listed in $string. You can modify the length of the string by changing the 25 in the for() statement to the length you desire. <?php $string = "abcdefghijklmnopqrstuvwxyz0123456789"; //List usable characters for($i=0;$i<25;$i++){ //Repeat 25 times $pos = rand(0,36); //We have 37 characters in our $string so we...

Read More
content top