This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| function is_valid_email($email, $test_mx = false) { | |
| if(eregi("^([_a-z0-9-]+)(\.[_a-z0-9-]+)*@([a-z0-9-]+)(\.[a-z0-9-]+)*(\.[a-z]{2,4})$", $email)) | |
| if($test_mx) | |
| { | |
| list($username, $domain) = split("@", $email); | |
| return getmxrr($domain, $mxrecords); | |
| } | |
| else | |
| return true; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /*------------------------------------------------*\ | |
| @email - Email address to show gravatar for | |
| @size - size of gravatar | |
| @default - URL of default gravatar to use | |
| @rating - rating of Gravatar(G, PG, R, X) | |
| \*------------------------------------------------*/ | |
| function show_gravatar($email, $size, $default, $rating) { | |
| echo '<img src="http://www.gravatar.com/avatar.php?gravatar_id='.md5($email). | |
| '&default='.$default.'&size='.$size.'&rating='.$rating.'" width="'.$size.'px" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| function truncate($string, $max_length = 50, $replacement = '...', $trunc_at_space = false) { | |
| $max_length -= strlen($replacement); | |
| $string_length = strlen($string); | |
| if($string_length <= $max_length) | |
| return $string; | |
| if( $trunc_at_space && ($space_position = strrpos($string, ' ', $max_length-$string_length)) ) | |
| $max_length = $space_position; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| function getDistanceBetweenPointsNew($latitude1, $longitude1, $latitude2, $longitude2) { | |
| $theta = $longitude1 - $longitude2; | |
| $miles = (sin(deg2rad($latitude1)) * sin(deg2rad($latitude2))) + (cos(deg2rad($latitude1)) * cos(deg2rad($latitude2)) * cos(deg2rad($theta))); | |
| $miles = acos($miles); | |
| $miles = rad2deg($miles); | |
| $miles = $miles * 60 * 1.1515; | |
| $feet = $miles * 5280; | |
| $yards = $feet / 3; | |
| $kilometers = $miles * 1.609344; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php echo 'class="'.<?php ($c++%2==1) ? 'odd' : 'even'.'"'; ?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $img = file_get_contents('monimage.png'); | |
| $img64 = 'data:image/x-icon;base64,'.base64_encode($img); | |
| echo '<img src="'.$img64.'"" />'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| function generate_rand($l){ | |
| $c= "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; | |
| srand((double)microtime()*1000000); | |
| for($i=0; $i<$l; $i++) { | |
| $rand.= $c[rand()%strlen($c)]; | |
| } | |
| return $rand; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $json ='{"id":0,"name":"Ashley","surname":"Ford","Website":"http://papermashup.com"} '; | |
| $array=json_decode($json); | |
| // print the array | |
| print_r($array); | |
| echo $array->name; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $now = '2014-01-22'; | |
| $now = date("D d M Y", strtotime($now)); | |
| echo $now; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var max_height = 0; | |
| $("div.col").each(function(){ | |
| if ($(this).height() > max_height) { max_height = $(this).height(); } | |
| }); | |
| $("div.col").height(max_height); |