Please help me wi this code

Started on the old forum in May 2011 · view the original in the archive · old links redirect here

2 replies · 368 views · started 15 years ago · 1 min read

2 participants
marv Newbie · 7 posts #1

Hi all im still a newgie in php and am working on a script for my mobile site i got a free code that lists contens of a directory but it uses a deprecated eregi could anyone pls help me on replacing this function

<?php
$viewExt = '.html|.php|.css|.js|.txt';   // only filenames with these extensions will be displayed
$dirHandle = opendir('.');
while ($file = readdir($dirHandle)) {
 if ($file != '.' && $file != '..' && @eregi("($viewExt)$",$file) && !@eregi("^index.",$file)) {
  $stack[] = $file;   // append filename to an array
  }
 }
closedir($dirHandle);
sort($stack);
foreach($stack as $value) {
 echo '<a href="'.$value.'">'.$value.'</a><br>'."\n";
 }
?>
 

Thanks in Advance

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close