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 strip_string($str, $case) { | |
switch ($case) { | |
case "az": return preg_replace("/[^a-zA-Z]+/", "", $str); | |
case "num": return preg_replace("/[^0-9]+/", "", $str); | |
case "num+az": default: return preg_replace("/[^a-zA-Z0-9]+/", "", $str); | |
} | |
} | |
?> |
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 is_valid_email($s) { | |
return preg_match('/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/', $s); | |
} | |
function is_valid_username($s) { | |
return preg_match('/^[A-Za-z0-9-_]+$/', $s); | |
} | |
?> |
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 substr_count_array($haystack, $needle) { | |
$count = 0; | |
$haystack = strtolower($haystack); | |
foreach ($needle as $substring) { | |
$count += substr_count($haystack, strtolower($substring)); | |
} | |
return $count; | |
} | |
?> |
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
RewriteEngine On | |
RewriteBase / | |
RewriteCond %{REQUEST_FILENAME} !-f | |
RewriteCond %{REQUEST_FILENAME} !-d | |
RewriteRule . /controller.php [L] |
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 | |
/** | |
* | |
* Simple PHP Pagination | |
* | |
* @author Stichoza | |
* @link http://stichoza.com/ | |
* @email [email protected] | |
* @version 1.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 | |
/* Sort 2D Arrays | |
* | |
* Example: | |
* $user_array = Array( | |
* Array("id" => 521, "name" => "Aboriginal Anemia"), | |
* Array("id" => 281, "name" => "Chemical Crap"), | |
* Array("id" => 596, "name" => "Bloody Baphomet") | |
* ); |
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 parse_request($vars, $encode_html = false, $return = false) { | |
$vars = explode(",", $vars); | |
if ($return) { | |
foreach ($vars as $value) { | |
$value = trim($value); // trim extra spaces | |
$result[$value] = get_var($value, $encode_html); | |
} | |
return $result; // returns associative array | |
} else { |
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 | |
# usage: $array = array("name" => "Stichoza", "website" => "stichoza.com"); | |
# echo replace_identifiers("Visit {{name}}'s website at {{website}}", $array); | |
function replace_identifiers($string, $assoc_array) { | |
foreach ($assoc_array as $key => $value) { | |
$string = str_replace("{{".$key."}}", $value, $string); | |
} | |
return $string; | |
} | |
?> |
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
Show hidden characters
{ | |
"color_scheme": "Packages/Color Scheme - Default/Monokai Bright.tmTheme", | |
"font_face": "Consolas", | |
"font_options": | |
[ | |
"subpixel_antialias", | |
"gray_antialias" | |
], | |
"font_size": 12, | |
"highlight_line": true, |
OlderNewer