Jump to content

how do i get how many 30's there are in x amount and then strip the remainder


ricky spires

Recommended Posts

$count = 0;
while ($x >= 30) {
  $count = $count + 1;
  $x = $x - 30;
}
unset($x);
echo $count;

:smoker:

 

That's too efficient. You need to step through one by one

$count = 0;
$subCount = 0;
for ($i=0; $i<$x; $i++)
{
  $subCount++;
  if($subCount==30)
  {
    $count = $count + 1;
    $subCount = 0;
  }
}
echo $count;

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.