From: Jason Woofenden Date: Fri, 29 Jun 2007 04:23:08 +0000 (-0400) Subject: added format_int_0() X-Git-Url: https://jasonwoof.com/gitweb/?a=commitdiff_plain;h=83949aa6ed4f40e2f12a97cf8ffc68b1feb7f73f;p=wfpl.git added format_int_0() --- diff --git a/format.php b/format.php index e158bb3..c40f55e 100644 --- a/format.php +++ b/format.php @@ -45,6 +45,15 @@ function format_int($str) { return ereg_replace('^0*([1-9])', '\1', $str); } +# return 0 of there's no digits +function format_int_0($str) { + $str = format_int($str); + if($str == '') { + return '0'; + } + return $str; +} + function format_zip($str) { return ereg_replace('[^0-9]', '', $str); }