Skip to content

Instantly share code, notes, and snippets.

View AkenRoberts's full-sized avatar

Aken Roberts AkenRoberts

View GitHub Profile
<?php
$collection = [$obj1, $obj2, $obj3];
// Dumb way
$matches = array_reduce($collection, function ($matches, $object) {
if ($object->isMatch()) {
$matches[] = $object;
}
return $matches;
@AkenRoberts
AkenRoberts / regex.php
Created June 24, 2013 18:37
Help me break this time regex!
<?php
/*
I'm trying to validate times in a PHP application. Some of the formats
I want to allow include:
- 12am (12 hour clock)
- 1:45 pm (space optional)
- 23:59 (24 hour clock)
- 00:16
@AkenRoberts
AkenRoberts / DB_query_builder.php
Last active April 22, 2016 17:03
Idea to help solve CodeIgniter Query Builder issue with SELECT strings being exploded at commas.
/**
* Select
*
* Generates the SELECT portion of the query
*
* @param string
* @param mixed
* @return CI_DB_query_builder
*/
public function select($select = '*', $escape = NULL)
@AkenRoberts
AkenRoberts / gist:3337417
Created August 13, 2012 06:25
Loop Solution for Philbish
<?php
$a = array();
$max_odd = 93;
$max_even = 72;
$prefix = 'B-';
$o = -1;
$e = 0;