PDA

View Full Version : very simple (i think) php question



themoose
November 8th, 2005, 13:33
ok, heres the code

<?php
foreach(glob("*.php") as $file)
{
print "$file";
}
?>

how do i make it ignore certain files (something like
if (file=index.php) {
print " ";
})
how would i put that into coding? (or have I just amazingly got that right? :P)
thanks
themoose

themoose
November 8th, 2005, 14:41
got it, its this:



<?php
$ignore = array("index.php", "login.php", "edit.php", "config.php", "processedit.php");
foreach(glob("*.php") as $file)
{
if (in_array($file, $ignore) )
{
print " ";
} else {
print "$file";
}
}

?>

ryza
November 12th, 2005, 22:55
if($foo==""){
//would be more correct

//not
if($foo=""){

Tree
November 13th, 2005, 11:23
Yep. Although some PHP configs will accept the assignment operator as the comparison operator, it's best to use == in if statements.