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
#Brittany Schaefer | |
#CSC 115 2-01-2020 | |
#Program 3 | |
#Intro | |
print('Welcome to iCalculator') | |
#accumulators | |
add = 0 | |
sub = 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 buildUrl($uri, array $params) { | |
$matches = []; | |
$pattern = '{\s* ([a-zA-Z_][a-zA-Z0-9_-]*) \s*(?:: \s* ([^{}]*(?:\{(?-1)\}[^{}]*)*))?\}'; | |
$optionalSegments = '\[.*'.$pattern.'\]'; | |
$uri = preg_replace_callback('~'.$optionalSegments.'~x', function($match) use ($params) { | |
$uri = trim($match[0], '[]'); | |
if (isset($params[$match[1]])) { |
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
$bitsOn = ($parity = $num & 1) + !!($num & 2) + !!($num & 4) + !!($num & 8) + !!($num & 16) + !!($num & 32) + !!($num & 64); |
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 | |
$subject = <<<DATA | |
property=value property2="value2" property3='value3' | |
DATA; | |
$pattern = '( | |
(?:^|\s) | |
(?<name>[a-z]\w+) | |
(?:=) |
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_get_value($array, $index, $default = null){ | |
return array_key_exists($index, $array)?$array[$index]:$default; | |
} | |
?> |
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
// from http://stackoverflow.com/questions/6265596/how-to-convert-a-roman-numeral-to-integer-in-php | |
$romans = array( | |
'M' => 1000, | |
'CM' => 900, | |
'D' => 500, | |
'CD' => 400, | |
'C' => 100, | |
'XC' => 90, | |
'L' => 50, |