mkosmosports Posted October 30, 2006 Share Posted October 30, 2006 Hey.I want to set an if condition on a group of numbers...$group=$_GET["group"]; $num = array("1","2","3","4","5","6","7","8","9","10");if ($group != $num) //If the number represented by the group parameter is not among the numbers in the $num array{echo("sorry");}How come the above does not work for me?Upfront thanks to anyone who can help me out.. Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted October 30, 2006 Share Posted October 30, 2006 That doesn't work since you're comparing a value to an array. You want to use the function [url=http://www.php.net/in_array]in_array()[/url][code]<?php$group=$_GET["group"]; $num = array("1","2","3","4","5","6","7","8","9","10");if (!in_array($group,$num)) //If the number represented by the group parameter is not among the numbers in the $num array{ echo("sorry");}?>[/code]Ken Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.