hi,
i need a php code which work in such a way that it skip 2 digits after printing 2 digits:
example:
1,2, 5,6, 9,10, 13,14.........
i now some for looping techniques will do this but don't know hoe please help me
Skip 2 digits after print 2 digits
Moderator: General Moderators
- AbraCadaver
- DevNet Master
- Posts: 2572
- Joined: Mon Feb 24, 2003 10:12 am
- Location: The Republic of Texas
- Contact:
Re: Skip 2 digits after print 2 digits
Many ways:
Code: Select all
for($i=0; $i<=100; ($i % 2 == 0) ? $i+=2 : $i) {
echo ++$i . ',';
}
for($i=0; $i<=100; ($i % 2) ? $i : $i+=2) {
echo ++$i . ',';
}
for($i=0; $i<=100; !($i % 2) ? $i+=2 : $i) {
echo ++$i . ',';
}
for($i=1; $i<=100; $i++) {
echo $i . ',';
$i = ($i % 2 == 0) ? $i+=2 : $i;
}mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.