I am trying to remove undefined offset error from the following code but could not figure it how.
$number = 20;
$pack = 10;
$i = 0;
while ($number % $pack == 0)
{
$number = $number / $pack;
$i++;
}
list($firstpart,$secondpart)=explode('.', $number);
echo $firstpart;
echo '<br>';
echo isset($secondpart)? number_format($secondpart,0):'0';
This code gives me correct answer but it outputs the following error:
E_NOTICE : type 8 -- Undefined offset: 1 -- at line 11
How do I change my code to remove the error. In a case like when $number=20.5, there is no error. Thanks.