Jump to content


Photo

including readdir


  • Please log in to reply
No replies to this topic

#1 Twentyoneth

Twentyoneth
  • Members
  • PipPipPip
  • Advanced Member
  • 118 posts
  • LocationGlasgow, KY

Posted 05 April 2006 - 03:24 AM

*solved*

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

<?php

$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>";
             }
          }
   closedir($dh);
  } 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"?




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users