PHP Quick Reference

Great Paypal IPN and PDT Tutorials

Date: 05/17/2017, Author: Lostwake, Category: PHP Quick Reference

PDT Tutorial:

IPN Tutorial:

PHP Encoder

Date: 05/01/2017, Author: Lostwake, Category: PHP Quick Reference

Make PHP harder to read and steal:

REGEX Get Everything in a Pattern

Date: 12/21/2016, Author: Lostwake, Category: PHP Quick Reference

Great REGEX tip for getting almost any pattern:

preg_match ('/[Slide](.*?)[/Slide]/s', $content, $matches);

How to Have Multiple Bootstrap Sliders on the Same Page!

Date: 07/12/2016, Author: Lostwake, Category: PHP Quick Reference

I have three carousels running at the same time, each with their own unique ID. They're being called using an attribute selector like so:


So each carousel has an id that begins exactly with the ID of #myCarousel and then a number to set them apart.

But you can also define an instance for each carousel on the same line, for example: (Notice how each selector is separated by a comma.)

$('#myCarousel1, #myCarousel2, #differentCarousel3').carousel();

And it will work as well, so just make sure you use a valid selector for each instance of your carousels.

Source: stackoverflow

Simple Social Share Buttons without Annoying Javascript Code

Date: 02/27/2016, Author: Lostwake, Category: PHP Quick Reference

I dont know why this was so hard to find but I finally found a post that explains how to build some simple social share buttons without obnoxious javascript or markup code and buttons that need to be re-styled.

You can see the product of this post in the top-right corner of this site.

I found the original post here:

Here is the code for each social network.


a href="       
target="_blank">Share on Facebook

Category Images in Main Menu on Opencart 2.0.x

Date: 02/25/2016, Author: Lostwake, Category: PHP Quick Reference

Ok so here is a hack for Opencart to get category images in the sub-categories of the main menu.

I was using Opencart when I did this.

We will need to edit two files to make this happen the first is: catalog/controller/common/header.php

We are going to start around line 113 and change this code:


// Level 2
            $children_data = array();

            $children = $this->model_catalog_category->getCategories($category['category_id']);

            foreach ($children as $child) {
                $filter_data = array(
                    'filter_category_id'  => $child['category_id'],
                    'filter_sub_category' => true

                $children_data[] = array(
                    'name'  => $child['name'] . ($this->config->get('config_product_count') ? ' (' . $this->model_catalog_product->getTotalProducts($filter_data) . ')' : ''),
                    'href'  => $this->url->link('product/category', 'path=' . $category['category_id'] . '_' . $child['category_id'])

Keyword Extractor for Dynamic Keywords in a PHP Webpage

Date: 11/05/2015, Author: Lostwake, Category: PHP Quick Reference

This script can analyze text on a page and filter out the most used words to include in the Keywords Meta Tag.

Quite useful as a fallback on pages where you wont be entering custom keywords and dont want to run into a duplicate keyword error on Webmaster Tools.

The first thing the function defines is a list of "stop" words. This is a list of words that occur quite a bit in English text and would therefore interfere with the outcome of the function. The function also uses a variant of the slug function to remove any odd characters that might be in the text.

Put Data In a URL with PHP

Date: 10/12/2015, Author: Lostwake, Category: PHP Quick Reference

I always forget the syntax for this so I'm posting it here for anyone who needs it.

The syntax for URL Encoding is as follow:

echo 'Link Code';

The text after the question mark is the $_GET variable then a string can be placed after the equals sign.

To get the information back out use the following:

$data = $_GET['foo'];

Get The Current Year With PHP

Date: 10/09/2015, Author: Lostwake, Category: PHP Quick Reference

I use the date function on php to get the date and time for my application.

Below is an example of displaying just the year.

echo date("Y");

And this is one displaying everything. You can play with the variables to get what you want.

echo date("Y-m-d H:i:s",time());

Leave a comment if you have questions or see an error.