Jump to content

Recommended Posts

Hi all,

 

Please check this out:

 

<?php
$get_subscribed_players1 = "SELECT game_subscriptions.user_id FROM game_subscriptions WHERE game_subscriptions.game_id='".$game_id."' AND game_subscriptions.active='1'";
		$run_subscribed_players1 = mysql_query($get_subscribed_players1);


//Get the array of currently active players in this game
for($k=1; $k<=$num_subscribed_players1;){ // FOR 107

	while($array_subscribed_players = mysql_fetch_assoc($run_subscribed_players1)){ // While 107
		$array_user_id = $array_subscribed_players['user_id'];

		if($k!=$num_subscribed_players){ $array_comma = ",";} else {$array_comma = "";}
		$array_of_subscribers.="'".$array_user_id."'".$array_comma;

		$k++;
	}// While 107
}// FOR 107


$needle = '10';
$test_array = array($array_of_subscribers);


if(in_array($needle, $test_array)){ // IF 138

		echo "Signed in - In Array";

	}  else if(!in_array($needle, $test_array)){ // IF 138

		echo "Signed in - NOT In Array";

	} // IF 138
?>

 

The code should be seeing that 10 is part of the array, and saying "Signed in - NOT In Array", but it's not seeing the number in the array. Can anyone see what I might be doing wrong here?

 

 

Thanks,

Woolyg

Link to comment
https://forums.phpfreaks.com/topic/143425-in_array-weirdness/
Share on other sites

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.