Jump to content

in_array weirdness..


woolyg

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.