X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=format.php;h=1bac60910ffdebe9cd4fa37439365549a9bf6e77;hb=484e7d7390f43456f0dbee648fa9a4e6854401fa;hp=d5fb32bef179e2490a424f1767670db659964974;hpb=a4814b960c7aabf4c6432c122fa0da675d5681b3;p=wfpl.git diff --git a/format.php b/format.php index d5fb32b..1bac609 100644 --- a/format.php +++ b/format.php @@ -4,28 +4,44 @@ # # This file is part of wfpl. # -# wfpl is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2, or (at your option) +# wfpl is free software; you can redistribute it and/or modify it under the +# terms of the GNU Lesser General Public License as published by the Free +# Software Foundation; either version 2.1 of the License, or (at your option) # any later version. # -# wfpl is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. +# wfpl is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for +# more details. # -# You should have received a copy of the GNU General Public License -# along with wfpl; see the file COPYING. If not, write to the -# Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -# MA 02111-1307, USA. +# You should have received a copy of the GNU Lesser General Public License +# along with wfpl; if not, write to the Free Software Foundation, Inc., 51 +# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # This file contains basic encodings function format_int($str) { + $str = ereg_replace('[^0-9]', '', $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); @@ -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"); - ?>