Jump to content

cannot get this array of value compared with the session id superglobal


Recommended Posts

no matter what i tried , nothing is working and i have tried every single array functions. i need to compare  $value1 with the $_SESSION['id']

$winners1[] = array_slice($WINNERSID, 0, $num_winners3);
if ($winners2 = array_filter($winners1)) {
	foreach ($winners2 as $value1) {
		

						if (in_array(intval($_SESSION['id']), $value1) && $prizepaid == false)  {

value1 contains this: array(2) { [0]=> string(2) "24" [1]=> string(2) "25" }

normally i believe it shouldnt be so complicated to see if the user id is the same as one of those numbers from the array..  

28 minutes ago, ginerjm said:

Just a quick thought - doesn't the function in_array kinda do this for you?  Your code is only looking for a single array element, no?  So it's s/b quick

dont worry i finally got it working after a week stuck on this 

 $WINNERSID[] = intval($WINNERS_ROW['participationid']);
$winners1[] = array_slice($WINNERSID, 0, $num_winners3);
if ($winners = array_filter($winners1)) {
	foreach ($winners as $value) {
						if (in_array($_SESSION['id'], $value) && $prizepaid == false)  {

i simply removed the intval() from the $_SESSION id and stored the ids as int into the winnersid array. i so much tried every single thing i could on this one this has to be the simplest thing i had to change .. this is hilarious .

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.