Hey,
Ik zit mn oude backups te ordenen zodat ik Windows 7 kan installeren, en ik kwam een oud scriptje van me tegen.
Je hebt er niets aan, maar het idee erachter is wel leuk. Je kunt de dag van de week berekenen zonder een datumfunctie te gebruiken.
Het script:
Ik meen me te herinneren dat hij niet voor alle jaartallen werkt, maar dat weet ik niet precies meer.
De uitleg ervan vind je hier:
Engels: http://en.wikipedia.org/wiki/Calculating_the_day_of_the_week
Nederlands: http://nl.wikipedia.org/wiki/Berekening_dag_van_de_week
Je hebt er niks aan zoals ik al zei, maar misschien dat iemand t leuk vind ofzo, geen idee.
Lennard.
Ik zit mn oude backups te ordenen zodat ik Windows 7 kan installeren, en ik kwam een oud scriptje van me tegen.
Je hebt er niets aan, maar het idee erachter is wel leuk. Je kunt de dag van de week berekenen zonder een datumfunctie te gebruiken.Het script:
[COLOR= #0000BB]<?php
$datum[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]13 mei 2009[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$welke[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/explode"]explode[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000] [/COLOR][COLOR= #007700],[/COLOR] [URL="http://www.php.net/strtolower"]strtolower[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$datum[/COLOR][COLOR= #007700]));[/COLOR]
[COLOR= #0000BB]$maanden[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/array"]array[/URL][COLOR= #007700]([/COLOR]
[COLOR= #DD0000]januari[/COLOR] [COLOR= #007700]=>[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700],[/COLOR]
[COLOR= #DD0000]februari[/COLOR] [COLOR= #007700]=>[/COLOR] [COLOR= #0000BB]3[/COLOR][COLOR= #007700],[/COLOR]
[COLOR= #DD0000]maart[/COLOR] [COLOR= #007700]=>[/COLOR] [COLOR= #0000BB]3[/COLOR][COLOR= #007700],[/COLOR]
[COLOR= #DD0000]april[/COLOR] [COLOR= #007700]=>[/COLOR] [COLOR= #0000BB]6[/COLOR][COLOR= #007700],[/COLOR]
[COLOR= #DD0000]mei[/COLOR] [COLOR= #007700]=>[/COLOR] [COLOR= #0000BB]1[/COLOR][COLOR= #007700],[/COLOR]
[COLOR= #DD0000]juni[/COLOR] [COLOR= #007700]=>[/COLOR] [COLOR= #0000BB]4[/COLOR][COLOR= #007700],[/COLOR]
[COLOR= #DD0000]juli[/COLOR] [COLOR= #007700]=>[/COLOR] [COLOR= #0000BB]6[/COLOR][COLOR= #007700],[/COLOR]
[COLOR= #DD0000]augustus[/COLOR] [COLOR= #007700]=>[/COLOR] [COLOR= #0000BB]2[/COLOR][COLOR= #007700],[/COLOR]
[COLOR= #DD0000]september[/COLOR] [COLOR= #007700]=>[/COLOR] [COLOR= #0000BB]5[/COLOR][COLOR= #007700],[/COLOR]
[COLOR= #DD0000]oktober[/COLOR] [COLOR= #007700]=>[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700],[/COLOR]
[COLOR= #DD0000]november[/COLOR] [COLOR= #007700]=>[/COLOR] [COLOR= #0000BB]3[/COLOR][COLOR= #007700],[/COLOR]
[COLOR= #DD0000]december[/COLOR] [COLOR= #007700]=>[/COLOR] [COLOR= #0000BB]5[/COLOR]
[COLOR= #007700]);[/COLOR]
[COLOR= #0000BB]$year[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/strlen"]strlen[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$welke[/COLOR][COLOR= #007700][[/COLOR][COLOR= #0000BB]2[/COLOR][COLOR= #007700]]) ==[/COLOR] [COLOR= #0000BB]4[/COLOR] [COLOR= #007700]?[/COLOR] [URL="http://www.php.net/substr"]substr[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$welke[/COLOR][COLOR= #007700][[/COLOR][COLOR= #0000BB]2[/COLOR][COLOR= #007700]],[/COLOR] [COLOR= #0000BB]2[/COLOR][COLOR= #007700]) :[/COLOR] [COLOR= #0000BB]$welke[/COLOR][COLOR= #007700][[/COLOR][COLOR= #0000BB]2[/COLOR][COLOR= #007700]];[/COLOR]
[COLOR= #0000BB]$year[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/floor"]floor[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$year[/COLOR] / [COLOR= #0000BB]4[/COLOR][COLOR= #007700]) +[/COLOR] [COLOR= #0000BB]$year[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$month[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$maanden[/COLOR][COLOR= #007700][[/COLOR][COLOR= #0000BB]$welke[/COLOR][COLOR= #007700][[/COLOR][COLOR= #0000BB]1[/COLOR][COLOR= #007700]]] +[/COLOR] [COLOR= #0000BB]$year[/COLOR] [COLOR= #007700]%[/COLOR] [COLOR= #0000BB]7[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$day[/COLOR] [COLOR= #007700]= ([/COLOR] [COLOR= #0000BB]$month[/COLOR] [COLOR= #007700]+[/COLOR] [COLOR= #0000BB]$welke[/COLOR][COLOR= #007700][[/COLOR][COLOR= #0000BB]0[/COLOR][COLOR= #007700]] ) %[/COLOR] [COLOR= #0000BB]7[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/strlen"]strlen[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$welke[/COLOR][COLOR= #007700][[/COLOR][COLOR= #0000BB]2[/COLOR][COLOR= #007700]]) ==[/COLOR] [COLOR= #0000BB]2[/COLOR][COLOR= #007700])
{[/COLOR]
[COLOR= #0000BB]$welke[/COLOR][COLOR= #007700][[/COLOR][COLOR= #0000BB]2[/COLOR][COLOR= #007700]] =[/COLOR] [COLOR= #DD0000]20[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$welke[/COLOR][COLOR= #007700][[/COLOR][COLOR= #0000BB]2[/COLOR][COLOR= #007700]];
}[/COLOR]
[COLOR= #0000BB]$leap[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$welke[/COLOR][COLOR= #007700][[/COLOR][COLOR= #0000BB]2[/COLOR][COLOR= #007700]] %[/COLOR] [COLOR= #0000BB]4[/COLOR] [COLOR= #007700]==[/COLOR] [COLOR= #0000BB]0[/COLOR] [COLOR= #007700]||[/COLOR] [COLOR= #0000BB]$welke[/COLOR][COLOR= #007700][[/COLOR][COLOR= #0000BB]2[/COLOR][COLOR= #007700]] %[/COLOR] [COLOR= #0000BB]100[/COLOR] [COLOR= #007700]==[/COLOR] [COLOR= #0000BB]0[/COLOR] [COLOR= #007700]||[/COLOR] [COLOR= #0000BB]$welke[/COLOR][COLOR= #007700][[/COLOR][COLOR= #0000BB]2[/COLOR][COLOR= #007700]] %[/COLOR] [COLOR= #0000BB]400[/COLOR] [COLOR= #007700]==[/COLOR] [COLOR= #0000BB]0[/COLOR] [COLOR= #007700]?[/COLOR] [COLOR= #0000BB]1[/COLOR] [COLOR= #007700]:[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$leap[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]6[/COLOR] [COLOR= #007700]-[/COLOR] [COLOR= #0000BB]$leap[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$einde[/COLOR] [COLOR= #007700]= ([/COLOR] [COLOR= #0000BB]$day[/COLOR] [COLOR= #007700]+[/COLOR] [COLOR= #0000BB]$leap[/COLOR] [COLOR= #007700]) %[/COLOR] [COLOR= #0000BB]7[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$dagen[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/array"]array[/URL][COLOR= #007700]([/COLOR]
[COLOR= #DD0000]Zondag[/COLOR][COLOR= #007700],[/COLOR]
[COLOR= #DD0000]Maandag[/COLOR][COLOR= #007700],[/COLOR]
[COLOR= #DD0000]Dinsdag[/COLOR][COLOR= #007700],[/COLOR]
[COLOR= #DD0000]Woensdag[/COLOR][COLOR= #007700],[/COLOR]
[COLOR= #DD0000]Donderdag[/COLOR][COLOR= #007700],[/COLOR]
[COLOR= #DD0000]Vrijdag[/COLOR][COLOR= #007700],[/COLOR]
[COLOR= #DD0000]Zaterdag[/COLOR]
[COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$datum[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000] valt op een: [/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$dagen[/COLOR][COLOR= #007700][[/COLOR][COLOR= #0000BB]$einde[/COLOR][COLOR= #007700]];[/COLOR]
?> Ik meen me te herinneren dat hij niet voor alle jaartallen werkt, maar dat weet ik niet precies meer.

De uitleg ervan vind je hier:
Engels: http://en.wikipedia.org/wiki/Calculating_the_day_of_the_week
Nederlands: http://nl.wikipedia.org/wiki/Berekening_dag_van_de_week
Je hebt er niks aan zoals ik al zei, maar misschien dat iemand t leuk vind ofzo, geen idee.

Lennard.

