Jump to content

Archived

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

Twentyoneth

including readdir

Recommended Posts

*solved*

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

[code]<?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.";
  }

?>[/code]

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.