Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

This is probably easier that it seems...

Status
Not open for further replies.

buzzt

Programmer
Oct 17, 2002
171
CA
All I want to do is pass ALL the information from the array to the if statement without specifying {0],[1]... How do I do this?

$page = $_SERVER['PHP_SELF'];
$page = " . $page;
$except = array('a.php', 'b.php');

if ($page != $except[0])
{
Whatever code
}
else
{
Other code
}
 
I don't understand.

Since and if-block is not a function, it uses the same variable scope as the surrounding code. You don't have to pass it anything as all variables are available.

If you want to base the logical clause of the if-statement on an entire array, it's possible to do so, but you'll have to use meaningful PHP statements to operate on the array.



Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Looking for a dummy code i thing you are trying to know the name of the script to see if it is in the set defined by the array.

That will never work :)

If you are tring to do that, try this piece of code instead:

if (in_array(substr($_SERVER["SCRIPT_NAME"],1),$array))){
It's in the array
else
not in the array

Anikin
Hugo Alexandre Dias
Web-Programmer
anikin@anikin-skywalker.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top