Skip to content

Instantly share code, notes, and snippets.

@phpfiddle
Created May 21, 2018 10:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save phpfiddle/c1826004924625409be830316f141cef to your computer and use it in GitHub Desktop.
Save phpfiddle/c1826004924625409be830316f141cef to your computer and use it in GitHub Desktop.
[ Posted by Biswa Bandhu Bhandary ] This code generates the below pattern if we set modulus divider value 3 i = 0;j = 0; i = 1;j = 0; i = 2;j = 0; i = 3;j = 1; i = 4;j = 1; i = 5;j = 1; i = 6;j = 2; i = 7;j = 2; so on...
<?php
$i = 0;
$_SESSION['k'] = 0;
while ($i<1000){
do_mail($i);
$i++;
}
function do_mail($i) {
$j = 0;
$k = $_SESSION['k'];
echo "i->".$i;
if ($i%500 === 0 && $i !== 0){
$k += 1;
$_SESSION['k'] = $k;
}
$j = $i-($i-$k);
echo "j->".$j."</br>";
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment