php basics

Saturday, May 27, 2006

Basic Array Notes

fields[] = $f;  //pushes $f into array $fields
$o = fields[0]; //assigns fields[0] to $o


---------------------------------------------------------------
$fileNames = scandir( " something goes here" );
$textfiles = array();

foreach ($fileNames as $filename)
{
// loop through and save textfile
//
(.txt) names into another array
if(substr($filename, -4) == ".txt")
{
$textfiles[] = $filename;
}
}

// see if we have no textfiles
if (count($textfiles) <= 0)
{
// do whatever if you have none
die();
}

// print them out
foreach ($textfiles as $textfile)
{
// print them
echo $textfile;
}

0 Comments:

Post a Comment

<< Home