Lennard schreef:arrays zijn coolerEerdere citaten tonen
Wouterr schreef:Weinig?! Objecten zijn awesomeEerdere citaten tonen
Lennard schreef:Je moet [c]$interestArr = json_decode($_COOKIE[interests], true);[/c] doen want json_decode geeft standaard een object terug waar je weinig mee kunt.
[COLOR= #0000BB]<?php[/COLOR]
[COLOR= #FF8000]// If the cookie hasnt been set yet
// set it with an empty array[/COLOR]
[URL="http://www.php.net/if"]if[/URL] [COLOR= #007700](![/COLOR][URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_COOKIE[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]interests[/COLOR][COLOR= #007700]])) {[/COLOR]
[COLOR= #0000BB]$_COOKIE[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]interests[/COLOR][COLOR= #007700]] =[/COLOR] json_encode[COLOR= #007700]([/COLOR][URL="http://www.php.net/array"]array[/URL][COLOR= #007700]());
}[/COLOR]
[COLOR= #0000BB]$interests[/COLOR] [COLOR= #007700]=[/COLOR] json_decode[COLOR= #007700]([/COLOR][COLOR= #0000BB]$_COOKIE[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]interests[/COLOR][COLOR= #007700]]);[/COLOR]
[COLOR= #FF8000]// If the key exists, increase it[/COLOR]
[URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$interests[/COLOR][COLOR= #007700]->[/COLOR][COLOR= #0000BB]$groupID[/COLOR][COLOR= #007700]) {[/COLOR]
[COLOR= #0000BB]$interests[/COLOR][COLOR= #007700]->[/COLOR][COLOR= #0000BB]$groupID[/COLOR][COLOR= #007700]++;
}[/COLOR] [URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR]
[COLOR= #FF8000]// If not, set its value to 1[/COLOR]
[COLOR= #0000BB]$interests[/COLOR][COLOR= #007700]->[/COLOR][COLOR= #0000BB]$groupID[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]1[/COLOR][COLOR= #007700];
}[/COLOR]
[COLOR= #FF8000]// Be sure to set the cookie with setcookie and $_COOKIE
// so its changes are effective immediately[/COLOR]
[COLOR= #0000BB]$_COOKIE[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]interests[/COLOR][COLOR= #007700]] =[/COLOR] json_encode[COLOR= #007700]([/COLOR][COLOR= #0000BB]$interests[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/setcookie"]setcookie[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]interests[/COLOR][COLOR= #007700],[/COLOR] json_encode[COLOR= #007700]([/COLOR][COLOR= #0000BB]$interests[/COLOR][COLOR= #007700]),[/COLOR] [URL="http://www.php.net/time"]time[/URL][COLOR= #007700]() + ([/COLOR][COLOR= #0000BB]86400[/COLOR] [COLOR= #007700]*[/COLOR] [COLOR= #0000BB]365[/COLOR][COLOR= #007700]));[/COLOR] tadaa





Ik wil de hoogste 4 van die array hebben dus lijkt me een array fijner. Ik heb het nu al helemaal weekend dus het zit wel goed zo 

