[PHP] loop vraag

Pagina: 1
Acties:
  • 31 views sinds 30-01-2008

  • Reveal!
  • Registratie: November 1999
  • Laatst online: 14:04
In een loop als deze

PHP:
1
 for($x = 0; $x < 250; $x++) {


Hoe kan ik iets om de 5 bijvoorbeeld uitvoeren ?
Ik zat te denken aan iets van if (5 % $x == 0) ofzoiets maar kom er nie helemaal uit.....

  • Peter
  • Registratie: Januari 2005
  • Laatst online: 10-04 16:35
PHP:
1
2
<?php
for($x = 0; $x < 250; $x+=5) {


zoiets? :)

  • .daan
  • Registratie: Januari 2002
  • Laatst online: 23-09-2023

.daan

{visibility:hidden;}

PHP:
1
if($x % 5 == 0 )


zou dat dan moeten zijn geloof ik, dan doet ie het bij 0, 5, 10 enz.

public void ik()


  • NMe
  • Registratie: Februari 2004
  • Laatst online: 17:49

NMe

Quia Ego Sic Dico.

Niet 5 mod x, maar x mod 5. En dat had je prima zelf kunnen bedenken als je even had gekeken wat die %-operator eigenlijk doet. ;)

'E's fighting in there!' he stuttered, grabbing the captain's arm.
'All by himself?' said the captain.
'No, with everyone!' shouted Nobby, hopping from one foot to the other.


Dit topic is gesloten.