X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=format.php;h=a658dbba05f02dea7069388dcfb49711dde75db2;hb=21c47e88810e97fe5b727c9c2689f64533bf6452;hp=1ee11318b429e2a8b8b04d0bcd5a4dcd68988f6a;hpb=22d5fb7ab7d4ee86bd59e194387dca268bd577a1;p=wfpl.git
diff --git a/format.php b/format.php
index 1ee1131..a658dbb 100644
--- a/format.php
+++ b/format.php
@@ -26,6 +26,22 @@ function format_int($str) {
return ereg_replace('^0*([1-9])', '\1', $str);
}
+function format_zip($str) {
+ return ereg_replace('[^0-9]', '', $str);
+}
+
+function format_filename($str) {
+ $str = strtolower($str);
+ $str = ereg_replace('[^a-z0-9_.-]', '_', $str);
+ return ereg_replace('^[0-9.-]*', '', $str);
+}
+
+function format_varname($str) {
+ $str = strtolower($str);
+ $str = ereg_replace('[^a-z0-9_]', '_', $str);
+ return ereg_replace('^[0-9]*', '', $str);
+}
+
function format_oneline($str) {
$str = str_replace("\r", '', $str);
return str_replace("\n", '', $str);
@@ -36,10 +52,10 @@ function format_unix($str) {
}
function format_yesno($str) {
- if($str) {
- return "Yes";
+ if($str && $str != 'No') {
+ return 'Yes';
} else {
- return "No";
+ return 'No';
}
}
@@ -117,24 +133,4 @@ function format_phone($str) {
return $output;
}
-
-#function ftest($val) {
-# printf("$val: '%s'
\n", format_phone($val, true));
-#}
-#
-#echo "FORMAT TESTS
";
-#ftest("$3");
-#ftest("3.99");
-#ftest("3.5");
-#ftest("891234");
-#ftest("8221234");
-#ftest("82212334");
-#ftest("122313234");
-#ftest("1158221234");
-#ftest("1558221234");
-#ftest("12235513234");
-#ftest("122355123334");
-#ftest("1585552212334");
-#ftest("15855522123334");
-
?>