Free Code Snippets

PHP Relative Time Calculator

This PHP script calculates and returns an easy-to-read relative time stamp based on how long ago an event occurred in the past.
Views: 1,548 Price: Free

PHP Check Palindrome

This PHP script checks a string against it's reversed self to determine if it's a palindrome. A palindrome is a word, phrase, verse, or sentence that reads the same backward and forward. For example: Go deliver a dare, vile dog! Hint: Type "tacocat" in the demo and enjoy! :)
Views: 643 Price: Free

CSS3 Automatic Screen Resolution Background Changer

This CSS3 stylesheet uses @media queries to automatically size the correct background image depending on the user's screen resolution. When implemented properly, this technique will save bandwidth, reduce the number of http requests, and most importantly, speed up your visitor's experience by delivering only what they need.
Views: 620 Price: Free

PHP Age Calculator with Leap Year Precision

This PHP script calculates and returns a user's age in years, based on a specified date. Unlike other age calculators, this PHP script takes into consideration leap years which makes this script much more accurate.
Views: 602 Price: Free

JavaScript Money Format with Commas Thousands Separator

This JavaScript returns a number as formatted for United States currency, by grouping the digits in groups of three with a comma and forcing two decimal places.
Views: 587 Price: Free

JavaScript Trim String

This JavaScript removes any excess whitespace (spaces, tabs, line breaks, etc) from both sides of a string.
Views: 573 Price: Free

PHP Obfuscate E-mail Addresses for Privacy

This PHP script returns an obscured e-mail address to protect the privacy of the user.
Views: 545 Price: Free

PHP Remove Any Excess Whitespace

This PHP script removes any excess whitespace (spaces, tabs, line breaks, etc) from a string of text and allows just one consecutive space.
Views: 533 Price: Free

PHP Force HTML Entities

This PHP script returns all of the characters in a string as HTML entities. Using this function when publishing e-mail addresses can help prevent web spiders from harvesting the data to send you spam.
Views: 499 Price: Free

HTML5 Make Telephone Numbers Clickable

Making telephone numbers clickable for users on smartphones can improve their browsing experience.
Views: 494 Price: Free

PHP Obfuscate Bank Account and Credit Card Numbers

This PHP script masks all but the last four digits of a credit card or account number to protect the privacy and security of the user. It mimics the common practice of masking the payment method on sales receipts.
Views: 476 Price: Free

JavaScript Clear Form Fields with Confirmation Dialog

This JavaScript checks with the user to confirm that they meant to clear the form. Upon confirmation, it resets any radio button or select box to the default selected value, then clears any input fields and unchecks all checkboxes.
Views: 441 Price: Free

PHP Latitude and Longitude Converter

This PHP script calculates and converts the decimal value of any geographical latitude and longitude coordinates into easy-to-read degrees, minutes, and seconds.
Views: 351 Price: Free

PHP Google AdSense Responsive Banner Iframe Design

Google AdSense allows you to display another page when no ads are available. This PHP script randomly chooses from pre-determined ad text and displays your custom advertisements with the design identical to Google's text banners. This responsive HTML5 and CSS3 page is formatted based on available width. When viewed on small devices, it will display as an infinitely scrolling banner.
Views: 287 Price: Free

PHP Base 64 Inline Image URI Generator

This PHP script dynamically converts any self-hosted image into a base 64 data URI for optimal website performance.
Views: 474 Price: Free
Using my code?Buy me a coffee!
Scripts are Licensed with Creative Commons