Home > Blockchain >  how to generate infinite counter
how to generate infinite counter

Time:10-12

Do you suggest how to develop a counter that automatically produces this sequence for me until infinity?

> if($id_bilo_up<25000){
    >             $directoryUP = 'da0';
    >         }else if ($id_bilo_up>=25000 && $id_bilo_up<50000){
    >             $directoryUP = 'da25000';
    >         }else if ($id_bilo_up>=50000 && $id_bilo_up<75000){
    >             $directoryUP = 'da50000';
    >         }else if ($id_bilo_up>=75000 && $id_bilo_up<100000){
    >             $directoryUP = 'da75000';
    >         }else if ($id_bilo_up>=100000 && $id_bilo_up<125000){
    >             $directoryUP = 'da100000';
    >         }else if ($id_bilo_up>=125000 && $id_bilo_up<150000){
    >             $directoryUP = 'da125000';
    >         }else if ($id_bilo_up>=150000 && $id_bilo_up<175000){
    >             $directoryUP = 'da150000';
    >         }else if ($id_bilo_up>=175000 && $id_bilo_up<200000){
    >             $directoryUP = 'da175000';
    >         }else if ($id_bilo_up>=200000 && $id_bilo_up<225000){
    >             $directoryUP = 'da200000';
    >         }

CodePudding user response:

From comments, I better understood what you need:

$base=intdiv($id_bilo_up, 25000);
$directoryUP = 'da' . ($base*25) .'000';

This will do what you need, but keep in mind that this will break once $base*25>PHP_INT_MAX

  • Related