Jump to content


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


including readdir

Recommended Posts


add the directory infront of files, simple error...


$dir = "items/";

if(is_dir($dir)) {
   $dh = opendir($dir);
   while (($items = readdir($dh)) !== false) {
          if (!preg_match('|-|', $items) && $items !== '.' && $items !== '..') {
              echo "<tr><td align='left'>$items</td><td align='center'>$items-bprice.php</td></tr>";
  } else {
   echo "no files.";


This code will read the "items/" directory and put the file names in "$items", but for "$items-bprice.php" part of the code, I would to include what is inside "items/$items-bprice.php", which would be something like "$1.94". If I include("$item-bprice.php"); nothing shows up (using include outside of the echo, not in the statement). Is there a way to go about including "$items-bprice.php"?

Share this post

Link to post
Share on other sites


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.