X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=format.php;h=a0e2f85f02d3a8438c5b66eb8d5fa4542454deee;hb=59c2d4dd864a724f0940405fed4d61bb8aa1864c;hp=d5fb32bef179e2490a424f1767670db659964974;hpb=a4814b960c7aabf4c6432c122fa0da675d5681b3;p=wfpl.git diff --git a/format.php b/format.php index d5fb32b..a0e2f85 100644 --- a/format.php +++ b/format.php @@ -4,26 +4,38 @@ # # 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) { - return ereg_replace('[^0-9]', '', $str); + $str = ereg_replace('[^0-9]', '', $str); + return ereg_replace('^0*([1-9])', '\1', $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) { @@ -117,24 +129,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"); - ?>