How to remove array element by value
How to remove array element by value

It seems like a fairly trivial task, and such a function should be built into PHP’s core — but unfortunately, it’s not. So we have to find our own solutions for implementing this functionality. One such solution for removing an array element by its value is shown below:

if(($delete_key = array_search($search_value, $my_array)) !== false)
{
	unset($my_array[$delete_key]);
}

You could say it’s just two lines — and the functionality is ready.

read more...

How to get time of all timezones in PHP
How to get time of all timezones in PHP

To get an array of all time zones with their time offset from Greenwich, use the following function:

function get_time_timezones()
{
	$zones_array = array();
	$timestamp = time();
	
	$default_timezone = date_default_timezone_get();
	$timezone_list = timezone_identifiers_list();
	
	foreach ($timezone_list as $zone)
	{
		date_default_timezone_set($zone);
		$zones_array[$zone] = date('P', $timestamp);
	}
	
	date_default_timezone_set($default_timezone);
	
	return $zones_array;
}

read more...

How to generate a QR code for a website
How to generate a QR code for a website

In this short article, we’ll take a look at one way to generate a QR code using PHP.
According to the “brain” of our internet (Wikipedia), which rarely lies :), a QR code is:

QR code (Quick Response Code) — a trademark for a type of matrix barcode (or two-dimensional barcode), originally developed for the automotive industry in Japan.

To put it simply, a QR code is an image containing a square-shaped barcode. It can be scanned using a mobile phone (with the proper software installed) or a special scanning device.

Let’s get to the point

We won’t reinvent the wheel — to generate a QR code in PHP, we’ll use the ready-made library “phpqrcode” (thanks to the author!). The library can be downloaded from GitHub via this link.

The library is lightweight and consists of just a few dozen files totaling a little over 250 KB.

read more...

Custom layout on Bootstrap 3
Custom layout on Bootstrap 3

Hello! In this article, I want to share my experience of custom layout development using the Bootstrap 3 framework.

What exactly will we do?

  1. Learn how to install the SCSS version of Bootstrap via Bower
  2. Configure Bootstrap's grid and other framework settings (if needed)
  3. Include specific Bootstrap components in the final stylesheet

Project Configuration

First, let’s define the directory structure of our project. For example:

/_data
/scss
/bootstrap //This directory contains the Bootsrap files we modified
_bootstrap.scss //Connected components
_variables.scss //Variables
style.scss //Contains connections to other files
template.scss //Project styles
.bowerrc
bower.json
gulpfile.js
package.json
/assets //Contains scripts loaded by bower
/image //Images and project styles
index.php

read more...