Welcome To Snipplr
Everyone's Recent PHP Snippets
- All /
- JavaScript /
- HTML /
- PHP /
- CSS /
- Ruby /
- Objective C
Adds a Logout link to the end of your Primary Navigation is the user is logged in; else adds a Login link to the end of your Primary Navigation.
        
        
        
            0 
        
        
            1503 
        
                    posted 10 years ago by entreprenerds
            Simple PHP search with whole word extract and highlighted search word
        
        
        
            0 
        
        
            1503 
        
                    posted 10 years ago by flatearthcomms
            In SQL I can get this by adding AND to the join
LEFT JOIN installations i ON a.id = i.app AND i.page = :page
This way I get the installation info for an app that has an installation on the page, but I get null values on the columns for app's that...
        
        
        
            0 
        
        
            4442 
        
                    posted 10 years ago by satie83
            Show a list of active plugins on current site.
I use it for diplaying in ManageWP and transfer to documentation
        
        
        
            1 
        
        
            2497 
        
                    posted 10 years ago by ellegaarddk
            <p>Follow these steps to secure your Cakephp Website:</p>
<p>*Before you actually start using Security Component functionality, make sure you use $components = array (‘Security’, ‘Auth’) in the array so you can extend its functionality in...
        
        
        
            0 
        
        
            2444 
        
                    posted 10 years ago by cakephpexpert
            Source: https://css-tricks.com/snippets/wordpress/customize-login-page/
Put them in your theme functions.php or make it a plugin.
        
        
        
            0 
        
        
            1422 
        
                    posted 10 years ago by pauloc
            Show a list of days between two dates, using native php DateTime functions
        
        
        
            0 
        
        
            2032 
        
                    posted 10 years ago by snstro
            This is a common model used to run some common functions like CRUD functions, get reference data from table, check for dependencies etc. So in other model, we don't have to add those function repeatedly
        
        
        
            0 
        
        
            2512 
        
                    posted 10 years ago by invtr
            To use WordPress 4 Customizer API I'd need just to do 2 steps: define a data in the array, and call a custom registering function.
        
        
        
            1 
        
        
            2391 
        
                    posted 10 years ago by micklevin
            This is the basic code that you need to know to connect and list data with PDO.
Don't use de old method (mysql_connect and mysqli_connect) to connect and interact with databases.
        
        
        
            0 
        
        
            2581 
        
                    posted 10 years ago by snstro
            This is a little code snippet that I use in almost every project that isn’t based on a popular CMS. Since its fairly expensive to hit the database on every page load, its a smart idea to cache the plain HTML markup of your page and serve that up. Y...
        
        
        
            0 
        
        
            2432 
        
                    posted 10 years ago by a1ias
            Simple script to send SMS throught our HTTP API (Afilnet) with PHP. Steps:
1.- Register in Afilnet. http://www.afilnet.com/anunciante/registrar.php
2.- Login and get credits (10 free) to send SMS
3.- Use this script or html form example include in...
        
        
        
            1 
        
        
            2559 
        
                    posted 10 years ago by Afilnet
            Search and returns the first results on a regex search
If we use parenthesized or subpattern, can return with $result_number
        
        
        
            0 
        
        
            1315 
        
                    posted 10 years ago by jatubio
            Build a regex expression to all array elements are present in any order.
Gets an array of strings (Sample: array("Access Denied","error","could not be retrieved")
Return sample: '(?=.*Access Denied)(?=.*error)(?=.*could not be retrieved)
        
        
        
            0 
        
        
            2406 
        
                    posted 10 years ago by jatubio
            Replaces spaces by '\s+' which means one or more spaces
$string can be one string or one array of strings
        
        
        
            0 
        
        
            1312 
        
                    posted 10 years ago by jatubio
            Translate non alphanumeric characters into an underscore. Doesn't create double underscores if there's two spaces in a row. Also turns name to lowercase. Use with trim to avoid spaces at front or end.
        
        
        
            0 
        
        
            3036 
        
                    posted 10 years ago by flatearthcomms
            To retrieve the weather forecast for your location based only on your current IP, the full tutorial will have the following 5 sections (http://bit.ly/1A5Y651), that will:
- Describe elements needed for weather forecast retrieval
- Describe the weat...
        
        
        
            0 
        
        
            2679 
        
                    posted 10 years ago by Hexahow
            Sort & query arrays in PHP. Sort multi dimensional arrays by object properties and filter the array by specific criteria.
Documentation:
https://github.com/mattnicholson/DataList
        
        
        
            1 
        
        
            1631 
        
                    posted 10 years ago by mattnicholson
            The code below can be used to lookup IP address in bulk in return of geolocation information using PHP programming languages and MySQL database. In this tutorial, we use the IP2Location LITE database to lookup country of origin from the visitor's IP...
        
        
        
            1 
        
        
            3040 
        
                    posted 10 years ago by Hexahow
            Use PHP's DOM parser to convert a table into plain text (including links with images)
        
        
        
            0 
        
        
            3362 
        
                    posted 10 years ago by nigelnquande
            This function takes HTML input and converts it to plain text. It needs improvement so that it converts multiple blank lines to a single blank line and converts an <a ... > link to the markup equivalent (same for images). It should be rewritten...
        
        
        
            0 
        
        
            2656 
        
                    posted 10 years ago by nigelnquande
            Bei Autocomplete aus größeren Datenbanken ist es sinnvoll, die Datenbankabfrage in eine separate php-Datei zu verlegen.
        
        
        
            0 
        
        
            1389 
        
                    posted 10 years ago by ulfinger
            Magento Testimonials extension add testimonials functinality to your store. Let everyone know what your customers think about your store.
You can add photo, email, website url and rating to your testimonials. Show testimonials on sidebar or separa...
        
        
        
            0 
        
        
            1395 
        
                    posted 10 years ago by steelgray9
            Ultratabs extension will provide you with power to display, hide and change order of core Magento tabs on product details page. Such as: Description, Additional Information, Upsell Products List, Related Products List, Products Tags and Products Revi...
        
        
        
            0 
        
        
            2391 
        
                    posted 10 years ago by steelgray9
            
