This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function array_flatten(Array $array, Array $out = array()) { | |
foreach($array as $value) | |
is_array($value) ? $out = array_flatten($value, $out) : $out[] = $value; | |
return $out; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function MobWritePatcher($text, $patch) { | |
$pointer = 0; | |
foreach(explode("\t", $patch) as $step) { | |
$modifier = substr($step, 0, 1); | |
$argument = substr($step, 1); | |
switch($modifier) { | |
case '=': |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class MobWrite { | |
protected $user = 0; | |
protected $file = NULL; | |
protected $datastore; | |
protected $diffengine; | |
public function __construct($datastore, $diffengine) { | |
$this->datastore = $datastore; | |
$this->diffengine = $diffengine; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function split_chunks($input) { | |
$offset = 0; | |
foreach(array_slice(func_get_args(), 1) as $length) { | |
$out[] = substr($input, $offset, $length); | |
$offset += $length; | |
} | |
return $out; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function mod_querystring($name, $value = NULL) { | |
$vars = $_GET; | |
$vars[$name] = $value; | |
return http_build_query($name); | |
} | |
print http_build_query(array('hej'=>'tjo', 'hepp'=>'happ','haha' => NULL)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
nth($what = 2, $loop = 'default') { | |
static $loops = array(); | |
return ($loops[$loop] % $what == 0); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function swedish_date($date = NULL) { | |
if(is_null($date)) | |
$date = time(); | |
elseif( ! is_numeric($date)) | |
$date = strtotime($date); | |
set_locale(LC_TIME, 'sv_SV'); | |
return strftime('%A den %e %B %Y' , $date); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function rollover($max, $value) { | |
return $value < $max ? $value : rollover($max, $value - $max); | |
} | |
function caesar_cipher($string, $offset = 3) { | |
$letter_numbers = array_map('ord', str_split(strtolower($string))); | |
foreach($letter_numbers as &$number) | |
if($number >= 97 && $number <= 122) | |
$number = rollover(25, $number - 97 + $offset) + 97; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function word_pairs($string, $min_matches = 1) { | |
$pair_counts = array(); | |
$words = explode(' ', $string); | |
$previous_word = FALSE; | |
foreach($words as $word) { | |
if($previous_word) | |
$pair_counts[$previous_word.' '.$word]++; | |
$previous_word = $word; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
include('posts_model.php'); | |
$posts = get_posts(); | |
include('view.php'); |
OlderNewer