Jump to content

Coding help, PLEASE?


Moron

Recommended Posts

Okay, I finally have the code I need, BUT.... I need to do one thing: truncate the ".txt" off of filenames in the display list. My code is:

 

<?php

echo "<center>";
echo "<font size=\"5\" color=\"#000000\" face=\"times new roman\"><b>Page Title</b></font>";
echo "</center>";
echo "<center>";
echo "<font size=\"8\" color=\"#000000\" face=\"times new roman\"><b>Bid Requests</b></font>";
echo "</center>";

$file = basename($path);

$path = './bidfolder/'; 

$handle = opendir($path); 
while (false !== ($file = readdir($handle))) 
{ 
if ($file != '.' && $file != '..') 
{ 
$filemtime = filemtime($path . $file); 
$file_array[$file] = $filemtime; 
} 
} 

$path_parts = pathinfo('/www/htdocs/index.html');


asort($file_array); 
echo "<BR><BR>";
foreach ($file_array as $key => $value) 
{ 

echo htmlspecialchars(ucfirst(preg_replace('/\..*$/', '', $file)));

echo "<center>";

echo "<font size=\"3\" color=\"#000000\" face=\"arial\">";

echo $key . '<br><br>'; 

readfile($path . $key); 

echo "<BR><BR>";

echo "<img src='http://www.website.org/images/bidbar.jpg'>";
echo "<BR>";
echo "<BR>";
echo "</font>";
echo "</center>";
} 
?>

 

What this is doing is...

 

1. Displays the filenames from a folder called "bidfolder."

 

2. Displays the contents of each file below the filename.

 

The "preg_replace" is no longer working for this. Is it just in the wrong place, or would I be better off using pathinfo or basename?

 

This part will totally complete my project and any help is greatly appreciated.

 

 

Link to comment
https://forums.phpfreaks.com/topic/57640-coding-help-please/
Share on other sites

Archived

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

×
×
  • Create New...

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.