/**
* A palindrome is a word which reads the same backward or forward,
* such as madam or kayak
*
* Implement a function that returns true if a word is a palindrome
* and false otherwise
*
FROM php:7.0.4-fpm | |
RUN apt-get update && apt-get install -y libmcrypt-dev \ | |
mysql-client libmagickwand-dev --no-install-recommends \ | |
&& pecl install imagick \ | |
&& docker-php-ext-enable imagick \ | |
&& docker-php-ext-install mcrypt pdo_mysql |
Generate Strong Password with PHP
$length = 8;
$characters_pool = 'luds';
$sets = array();
if (strpos($characters_pool, 'l') !== false) {
$sets[] = 'abcdefghjkmnpqrstuvwxyz';
}
if (strpos($characters_pool, 'u') !== false) {
$sets[] = 'ABCDEFGHJKMNPQRSTUVWXYZ';
How to Implement URL Signing for HighWinds CDN in PHP:
//the input URL example taken from https://support.highwinds.com/display/DOCS/Content+Protection
$URL = parse_url("http://aaa.wdd3.cdn.net/secure123/content.mp4");
// parse URL to separate the host and the rest of the url string
$uri= $URL['path'];
// set a secret pass
$secret = 'abcdef123';
Git Tagging and Branching 101
Here are the best practices for using Git Branches and Git Tags:
Git Tags
A ref pointing to a tag or commit object. To put simply, a tag is a way to mark a point in time in your repository. Here are some things that you should keep in mind when working with tags:
-You should add a tag to mark a released version. If you then need to make bug fixes to that release you would create a branch at the tag
Select similar (autofill) city names from maxmind cities list as compared to the input string in CodeIgniter
Model
class Maxmind_model extends CI_Model {
private $table = "maxmind";
public function __construct() {
PHP API to return table names from a given SQL statement with multiple tables
Input
$query = "SELECT `main_categories`.*, `categories_views`.`view` AS view_ctg, (SELECT COUNT(id_geo) FROM main_geo WHERE id_geo=geo_filter_ctg AND FIND_IN_SET('PK', `countries_geo` )) as countryCount
FROM (`main_categories`)
JOIN `categories_parents` ON `main_categories`.`id_ctg` = `categories_parents`.`id_ctg`
JOIN `categories_views` ON `main_categories`.`id_ctg` = `categories_views`.`id_ctg`
WHERE categories_parents
.parent_ctg
= '8701'
Best way to use data fetched from DB with result_array()
$result = $this->db->get()->result_array(); // result_array() itself uses a for loop so we actually end up looping twice in the next line
foreach ($result as $row)
{
...
}
Instead use: