Snippets for Website Development
Load CSV Into a 2-d Array Using PHP - Code shows how to load a CSV file into a two-dimensional PHP array.
Convert a PHP 2d-Array to CSV - Convert a 2-dimensional PHP array into a CSV string
Load CSV File Into PHP 1-d Array - Loads a flat csv file into a php array as a one-dimensional array.
Calculate Script Execution Time - Calculate the time it takes to execute a PHP script.
Round a PHP 2d Array by a Specified Key - Round a 2-dimensional array by a key. For example, sort array[$i] sorts all $i by the 2nd key.
Get the Distance Between Two Points in Latitude and Longitude - Find the distance between two sets of latitude and longitude points.
Loop for a Period of Time - Loop for a period of time, performing calculations. When specified time period has elapsed exit the loop.
Loop Structures in PHP - Illustrates several looping structures in PHP for various conditions.
Use PHP to Get the Links from an HTML Page - Get the links from an HTML page using PHP
Remove the Last Character From a PHP String - Remove the last character from a string in PHP
Determine if PHP String Contains a Substring - PHP function returns boolean true if the substring is contained in the string.
Insert an Element into a PHP Array - Insert a new element into a PHP array at a given location, reordering the array.
Get Contents of Directory in PHP - Retrieve the contents of a directory on the server and put the contents in an array.
Dynamically Load Content Without AJAX - Load content into a div without using AJAX or JQuery.
Get Map Directions on Google Maps - Get directions using Google maps. The starting location is input by the user, the ending location is a static address.
Basic HTML Template - This is the code for a basic HTML template to get a webpage started from scratch.
Open Two Pages With One Link - Opens two pages at the same time. One link click opens a new link in a new tab, while also opening the current page to a new page.
Open URL Using Button in Same or New Window - Opens a URL in either the same window or a new window.
Indent HTML text Multiple Levels - Indent HTML text multiple times or levels. Indent within indent as often as you want.
Dynamically Resize a DIV or Other HTML Element - Resize a div or any other HTML element using grips similar to a textarea.
Data Image Used as a Placeholder for Spacing - Use a transparent data-image as a placeholder for spacing, or for an overlay link or any other purpose. Loads with the page, not the server so it's fast and efficient.
Strip HTML Tags from String - Remove all HTML tags from a string. If a user submits comments or other content, HTML tags need to be stripped in order control formatting.
Remove Quotes from String - Remove quotes from a string so it can be used in a csv file or any other situation where allowing quotes would cause the string to terminate prematurely.
Remove Return Characters From String - Remove return characters from a string. This is useful for sanitizing text which was input by a user.
Fade an Element In or Out with a Toggle - Fade an element in or out using a toggle button.
Copy Text to Clipboard - Copy text from an input box to the clipboard.
Determine When HTML Element Comes Into Viewport While Scrolling - Determine when an HTML element comes into view while scrolling.
CSS Button - Create a button effect on an element such as a div or span with CSS.
Adjust Image Responsive to Screen Size - Responsively adjust image size as screen size changes.
Horizontal Rule with Gradient Fade Out of Ends - Demonstrates using a horizontal rule (
Tab Menu Using CSS Only - Create a tab style menu using CSS only, no images.
Fade-in a Page or Element on Page Load - Fade in the contents of the page on load. This technique can be applied to a whole page or an element within the page.
Timer Shown by Progress Bar - Show a time delay with a progress bar using only CSS
Make Columns Break at New Paragraph - Not Within a Paragraph - Make columns break at new paragraph, not in the middle of a paragraph.
Center Image Vertically and Horizontally - Center and image within a div vertically and horizontally
Pulse An HTML Element Using CSS - Make an HTML element pulsate using CSS