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
function titleCase($string) { | |
//reference http://grammar.about.com/od/tz/g/Title-Case.htm | |
// The below array contains the most commonly non-capitalized words in title casing - I'm not so sure about the commented ones that follow it... | |
$minorWords = array('a','an','and','as','at','but','by','for','in','nor','of','on','or','per','the','to','with'); // but, is, if, then, else, when, from, off, out, over, into, | |
// take the input string, trim whitespace from the ends, single out all repeating whitespace | |
$string = preg_replace('/[ ]+/', ' ', trim($string)); | |
// explode string into array of words | |
$pieces = explode(' ', $string); | |
// for each element in array... | |
for($p = 0; $p <= (count($pieces) - 1); $p++){ |
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 | |
abstract class Command { | |
abstract public function unExecute (); | |
abstract public function Execute (); | |
} | |
class concreteCommand extends Command { | |
private $operator,$operand,$calculator; | |
public function __construct ($calculator,$operator,$operand) { | |
$this->operator = $operator; | |
$this->operand = $operand; |
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 | |
#source: http://stackoverflow.com/questions/2934563/how-to-decode-unicode-escape-sequences-like-u00ed-to-proper-utf-8-encoded-char | |
function replace_unicode_escape_sequence($match) { | |
return mb_convert_encoding(pack('H*', $match[1]), 'UTF-8', 'UCS-2BE'); | |
} | |
function unicode_decode($str) { | |
return preg_replace_callback('/\\\\u([0-9a-f]{4})/i', 'replace_unicode_escape_sequence', $str); | |
} |