Jump to content

Interger


june_c21

Recommended Posts

idk, there probably is a function already.. but i made this:

 

---

// preceding zero's function: Wes Foster
// argument 1 - the int you choose
// argument 2 -how many digits you would like the number to be (3 in this case)
function precede($int,$digit)
{
   if ( strlen($int) < $digit )
   {
      $count = $digit - strlen($int);

      for ($i=0;$i<$count;$i++)
      {
         $final .= "0";
      }

      $final .= $int;
   }

   return $final;
}

---

 

and use like:

 

the $int is 59.

$int = precede($int,3);

now, $int will be "059"

Link to comment
https://forums.phpfreaks.com/topic/78349-interger/#findComment-396432
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.