Reverse Order Of Directory Listing

Jul 8, 2007

I am using the following code to list the subdirectories under a main directory.  However, I want to reverse the order that they are currently listing in.  Preferably, I would like them to list based on each sub-directory's last modification time, with the most recently modified directories at the top of the list.

<?php
if ($handle = opendir('/some_directory')) {
    while (false !== ($file = readdir($handle))) {
        if ($file != "." && $file != "..") {
            echo "$file";
        }
    }
    closedir($handle);
}
?>

ADVERTISEMENT

Reverse The Letters In Every Word Not Reverse The Words Order?

Jul 23, 2009

i have a string .

i want to reverse the letters in every word not reverse the words order.

like - 'my string'

should be

'ym gnirts'

View 5 Replies View Related

ORDER BY Timestamp Listing In Wrong Order?

Nov 15, 2009

I have a list of movie titles in a database each with a time stamp of the release date The query:

Code: [Select]<?php $getvideos = mysql_query("SELECT * FROM videolistings ORDER BY releasedate DESC")or die(mysql_error());?>
But for some reason the videos are not listing in descending order, EG: the videos on this page

[code]...

View 1 Replies View Related

Reverse Order Of XML?

May 11, 2011

I'm using PHP to output data from an XML file. It's defaulting to chronological order, which I'd like to reverse. Is this possible with PHP? If so, how?

Here's my page and code:

$file = 'http://www.gostanford.com/data/xml/events/m-baskbl/2010/index.xml';
$xml = simplexml_load_file($file);
foreach ($xml as $event_date) {
if(!empty($event_date->event['vn']) && !empty($event_date->event['hn']) && !empty($event_date->event['vs']) && !empty($event_date->event['hs']))
{
echo '<li>';.............

View 4 Replies View Related

Reverse Order

Apr 1, 2007

I have this line in a php script:

$sql3=@mysql_query("select url,text from recips where girl='$linkid' order by vote");

I want the order reversed.

View 1 Replies View Related

Reverse Order - Last Record

Sep 20, 2005

I would like to start at the end, say page 25, and the next to be 24, 23, 22 etc. to work in reverse. Guidance would be appreciated very much. (The problem is that the latest is always the last record, and there's where I need the pages to start.)

$next = $_GET['id'] + 1;
$previous = $_GET['id'] - 1;
$total = 45;

if ($previous > -1)
{
echo '<p><a href="?id=' . $previous . '">Previous</a> | '
}
if ($next <= $total)
{
echo '<a href="?id=' . $next . '">Next</a><br>'
}

View 2 Replies View Related

Searching Through And Listing A Remote Directory ( Directory Listings Enabled )?

Jul 28, 2010

I've been working on a script for a while now, and I'm sure it doesn't look great and all, and it's probably really messed up.. But right now I've finally got it working! There's only 1 thing I'd really like to add..Searching through & listing of remote directories! The directories I'm trying to list have directory listings enabled, and I think it *should* be possible. I just have no clue how.

Here's my current code in a beautiful mix of HTML and PHP:

<?
$border_size = "0";
function returner($what) {
$what=explode("/",$what);
$tps=count($what);
$what=$what[$tps-1];
return $what;

[Code]...

So right now my question to you PHP freaks is, *This* is one of the directories I wish to be able to search through & list..

View 3 Replies View Related

Reading A File In Reverse Order

Jul 17, 2005

I need to read a file (line-by-line) in reverse order, without reading the
whole file into memory first.

Is there an easy way of doing this? As in, is there a PHP function I could
use?

The solution has to be platform independent, so "popen("tac $filename")...
wouldn't work.

Example input and ouput:

<myfile.txt input>
line 1
line 2
line 3
</myfile.txt input>

<output from php script>
line 3
line 2
line 1
</output from php script>

View 14 Replies View Related

Fopen Reverse/limit Order

Aug 22, 2005

I have a log which is CSV file to display it Im using the script below, which works fine
how would it be possible to reverse the order.. or start with the last line being first. plus limit the results to the last 10 lines only? Code:

View 4 Replies View Related

Output A Date In Reverse Order

May 21, 2006

I am trying to output a date in reverse order to the way it is stored. I have looked at the php manual, but I am stumped as to how I actually echo it. The code to echo is as below.

echo("<h5>");
echo ($myrow["date"]);
echo("<br>");
echo ($myrow["venue"]);
echo("<br>");
echo ($myrow["town"]);
echo "<p>";
echo("</h4>");

How I actually change the format on the echo statement so that the output isdd/mm/yyyy?

View 9 Replies View Related

Reverse The Order When Echoing Results?

Jan 14, 2011

i have this bit of code:

<?php
$file = file_get_contents('http://example.com');
preg_match_all("/<a href=(.*?links.*?)>.*?</a>/i", $file, $a);
$count = count($a[1]);
for ($row = 0; $row < $count ; $row++) {
[Code]...

and currently it echos the links in order they appear on the website. I would like for it to echo the results in a reverse order (the last link on [URL] to echo as the first with this code)

View 3 Replies View Related

Session Var Is Assigned In Reverse Order?

Aug 21, 2010

Why the session var is assigned in reverse order.

$_SESSION['name'] = $myVar;
and not,
$myVar = $_SESSION['name'];

[code]...

And number two, my host has magic quotes turned on, so I have a little scriptie scrubbing all my php vars(post, get, cookie, etc.).When I added the session var, for example:$_SESSION = array_map('trim', $_SESSION);to the list, PHP generated an error saying session is not an array, or some such malarky.Now that I look at it, I don't need to do mysql-real-escape-string or strip-slashes to the session var since its not user input, but why would php say its not an array?or is this just an erroneous error report?

View 5 Replies View Related

Blogger Reverse Post Order

Mar 15, 2007

There's already a huge javascript out that does this but it's really robust. I've already gotten it working but PHP is such a hot mistress that I simply have to delve in.

What I want to do is rearrange content so that it lists chronologically (earliest date on top, latest date on bottom).

So far, my template is as follows (note that this is used to post upcoming concerts, so past shows are rendered "hidden") ... Code:

View 10 Replies View Related

Show The First 30 Records In Reverse Order

Oct 14, 2007

I have a table like this:
+-----------+-----------------------+
|   item id    |   item                        |
+-----------+-----------------------+
|      1         |       blah1                   |
|      2         |       blah2                   |
|      3         |       blah3                   |
|      4         |       blah4                   |
+-----------+-----------------------+

Awful diagram, sorry. Anyways, say this table goes on for, say, 60 records. Now, how do I show the first 30 records in reverse order. So, it would look like this:

blah30
blah29
blah28
blah27
blah26
blah25

etc. until it reached blah1. How do I do this?

View 3 Replies View Related

Reverse File Upload Order

Jun 2, 2007

I'm for some reason not able to reverse the array of files I'm uplading. I have a form for uploading 4 images at once. becuase it's javascript on the form, it adds a newfile browse and places the previous one below. that means though when you hit upload, the first file you selected is the last, and vice veras. on the process end I'm suing this

$photos_uploaded = $_FILES['photo_filename'];
$photos_uploaded = array_reverse($photos_uploaded, true);

true, makes no difference, and array_reverse makes no difference, I always get the last file first. for a sequential photo album, this is no good.

View 4 Replies View Related

Number Processing / Value Needs To Be Changed To The Reverse Order?

Aug 2, 2010

In a multidimensional array, each array has a field 'order'. I need to change this value as follows:

0 -> 3
1 -> 2
2 -> 1
3 -> 0
4 -> 7
5 -> 6
6 -> 5
7 -> 4
8 -> 9
9 -> 8

etc...

Ill be doing this while iterating through the array as follows

$c = 0;
foreach($data['images'] as $i)
{
//$i['order'] contains the original order value
$processed_imgs[$c]['file'] = $i['file'];
$processed_imgs[$c]['text'] = $i['text'];
$processed_imgs[$c]['order'] = 'X';
$c++;
}

$i['order'] contains the original order value (left column in the first code snippet, coming out of the DB ASC) and should be changed to the corresponding number in the right column.

So basically, the value needs to be changed to the reverse order, while looking at each set of numbers in blocks of 4. I will not know what the highest order number will be, it will increase as new images are added.

What's the best way to do this using the above foreach?

View 2 Replies View Related

Reverse Order On Output Of Custom Values

Jul 7, 2010

I am pulling out values from a series of custom fields named thumb:

<?php
$mykey_values = get_post_custom_values('preview');
foreach ( $mykey_values as $key => $value ) {
echo "<img src='$value' width='590' />";
}
?>

How do I reverse the order of the output?

View 3 Replies View Related

Sort An Array In Reverse Order Of Values?

Dec 4, 2010

I want to sort an array in reverse order of values. I used arsort php function but the result is not good for me.

Example:

I want to sort next array:
myArray = array("d" => 1, "f" => 2, "b" => 3, "c" => 4, "e" => 2);
after using arsort php function the result is:
myArray =array ( "c" => 4, "b" => 3, "e" => 2, "f" => 2, "d" => 1 );

which it is not good because the arsort function doesn't keep initial order of elements in array.

I want the result like:

myArray =array ( "c" => 4, "b" => 3, "f" => 2, "e" => 2, "d" => 1 );

f before e order, like from original array. keys with same value to not reverse.

View 5 Replies View Related

Gallery Thumbs Are Not Showing In Reverse Order?

Dec 6, 2010

What it's doing, or is supposed to be doing, is taking a thumb called 'thumb.jpg' from each folder within my gallery folder and displaying it in reverse order on a page. I only want a maximum number of images to display on the page at any one time, so that if I end up uploading loads of folders in the future, it will only display a set amount of thumbs on one page.

I want the thumbs displayed in reverse order, so that the newest appears first.

Here's the code... and as far as I can see, it should work... and I'm sure I have had it working in the past (I've just come back to working on it after a while) however now, it's putting the thumbs in a random order.

My folders are all in the gallery folder, and are named 001, 002, 003, 004, 005, 006, etc. I want them to display with 006 at the top and to de-increment, but only for the most recent 16 folders.

Code: [Select]
<?php
$images = "gallery/"; # Location of galleries 
$cols   = 4; # Number of columns to display 
$max     = 16; # Maximum number of galleries to show

[Code].....

View 14 Replies View Related

Sorting Files In Reverse Alphabetical Order

Feb 10, 2010

I have some code that displays the contents of each file from a given folder. The thing is it displays files alphabetically. I want to do the opposite (z to a). I've played around with the asort() function and can't seem to get it right.

<?php
if($handle=opendir('./files/')){
while(false!==($file=readdir($handle)))
{
if($file!="."&&$file!="..")

[Code].....

View 4 Replies View Related

Recursively Retrieve The Directory Listing Of A Given Directory?

Dec 18, 2007

I am trying to recursively retrieve the directory listing of a given directory that is, print out all files and folders (and sub folders) of a given directory. My function #1 does not work, however the function someone else has written #2 does. Why is this?

My Function #1:

<?php
function showDirectory( $directory )
{
echo("<BR>TESTING: ARG=". $directory);
$dir = opendir( $directory );
if ( $dir )
{
echo("<BR>TESTING: dir has been opened");

[Code]...

View 6 Replies View Related

File Listing In Alphabetical Order?

Jul 8, 2009

I'm using a script which displays the files from a specific folder, however I'd like them to be displayed in alphabetical order, would it be hard to do this? Here's the code I'm using:

if ($handle = opendir($mainframe->getCfg( 'absolute_path' ) ."/images/store/")) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {

[code]....

View 5 Replies View Related

Excluding A Directory From A Web Directory Listing?

May 20, 2011

I'm using WAMP.

I have 10+ folders in my "wwwmystuffs" folder. I have folder called temp. How do I hide this folder from directory listing and create a link to access files in that folder...?

View 3 Replies View Related

Directory Listing ...

Jul 17, 2005

I'm a newbie to PHP and need to be able to get a list of the
files/sub-directories from a particular directory on the server (ie: I
want to load the list of files in the program's current directory into
an array).

This must be possible but somehow I can't find the syntax in my
documentation.

Can someone send me a snippet of syntax? Or point me towards a good
'howto' that maybe has a catalogue of PHP commands?

View 3 Replies View Related

Directory(ONLY) Listing

Mar 4, 2003

How to make a directory listing with php using Directory Function. I dont want to list all files inside the directory but just the list of the subdirectory/subfolder inside.

View 2 Replies View Related

Php Listing A Directory?

Jul 22, 2005

is there a way in php to list a directory on the remote server...etc.

i have 4 files

blah.txt
test.html
fred.jpg
and
mel.doc

I want to search the given directory for *.html / htm files. then return them... ie i want to create a <select> option and value for each .html found.

View 2 Replies View Related

Get A Directory Listing By ID

May 8, 2007

Here is how I am uploading the files. PHP Code:

$ID = mysql_insert_id(); //get the id of the last to append to the beginning of the filenames

$filename1 = "/path to directory/staff/uploads/" . $ID . "-" . $FILE1_name ;
$filename2 = "/path to directory/staff/uploads/" . $ID . "-" . $FILE2_name ;

@copy("$FILE1" , $filename1);
@copy("$FILE2" , $filename2);
......

View 5 Replies View Related

Directory Listing

Oct 13, 2007

I recently wrote an upload script, and along with it when you uploaded it a directory listing script shows the files in the uploaded folder. Code:

View 6 Replies View Related

Listing Images From A Given Directory

Feb 16, 2003

I wish to list images (even thumbnails if possible) on a html site. The images should be placed in a given directory (URL). How do I get the list of images and perhaps even the list of directories? And secondary, but not so important - how do I display thumpnails of the images - e.g. resizing images.

View 12 Replies View Related

Directory Listing With Array

Jul 17, 2005

I need to wiev in a php page the listing of one on my directory in the
webserver.

can someone help me to understand how?

for every file in thw directory I need a row in a html file..

directory: /opt/dir

result:

file1
file2
file3
...

View 3 Replies View Related

Listing Aliased Directory

Jul 17, 2005

I have in Apache2 (win32) aliased directory, for example:

Alias /ftp/mp3/ "D:/mp3/"
<Directory "D:/mp3">
....
</Directory>

Address to this directory will be: http://localhost/ftp/mp3/

How can i list files in that directory?

# This works for full-path directory on my hdd, but not for aliased:
if ($handle = opendir($directory)) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
echo "$file
";
}
}
closedir($handle);
}

View 3 Replies View Related

Sorting The Directory Listing

Apr 9, 2002

I have a script that displays the list of a defined directory on my hard drive, but I'd like to have the outputed list of files to be sorted. Anyone know how I can do this? My code is below PHP Code:

View 4 Replies View Related

Directory Listing Script

Apr 23, 2003

I'm in need of a PHP script that will list the files in a specified directory and also link to those files.

View 9 Replies View Related

Generating Listing Of Directory

Nov 12, 2006

The server I use does not auto-generate
this. So, when someone comes to this directory and thus opens
index.htm, I want that file to show a listing of all files in the
directory with hyperlinks to them.

View 3 Replies View Related

Organisation Directory Listing

Mar 5, 2006

Is there any good directory listing script out there?

View 3 Replies View Related

Mp3 Directory Listing For Playlist.m3u

Jan 10, 2007

I have this script in my mp3 directory on my web server. It creates a list of all the files located in that directory just fine. But I would like it to display the full path of the files such as (http://www.mysite.com/music/testsong.mp3). I don't mind having to set the varable of (http://www.mysite.com/music/) within the script.

This way I could copy that info into a playlist file. Or if it could create a playlist.m3u file in the same directory that would be great....

View 3 Replies View Related

Directory Listing Pulling

Apr 11, 2007

A very simple directory listing isnt pulling all the files and I'm pulling my hairs trying to figure out why: PHP Code:

function DirReader($dir){
if ($handle=opendir($dir)){
while($file = readdir($handle)){
if (is_file($file)) echo "<b>".$dir."/</b>".$file." is a file<br><br>";
elseif ((is_dir($file)) && (trim(str_replace(".", "",$file)) !== "")) {
DirReader($dir."/".$file);
}
}
}
}

DirReader(".");

As you can see, not much to the code, but it seems to only pull 1 or 2 files, perhaps until it finds a directory, on any given directory.

View 5 Replies View Related

Remote Directory Listing

Feb 23, 2006

What permissions, if any, will I need access to, and what should I set them to in order to list all the files within a remote directory?

View 8 Replies View Related

Directory Listing Using Scandir

Dec 14, 2005

I am trying to get a file and directory listing from a website. The best option seems to be scandir (as it doesn't seem readdir supports http)

So, this is what I'm using. Note: giving it a local directory gives me the correct listing while a http directory does not. Anyone know why?

<?php
$files = scandir( "http://www.someweb.com/somedir/" );
for( $ctr = 0; $ctr < sizeof( $files ); $ctr++ ) {
echo $files[$ctr];
}
?>

View 11 Replies View Related

Directory Listing Control

Dec 22, 2006

I want to create a directory where I can drop stuff that people can download [for free]. I have a great php function that reads the directory and writes out a contents list with live links.

One problem, it also writes the single and double dots [. and ..] that lets people move out of the current directory list. This I need to eliminate. I only want the list of actual contents without the change directory links.

[?php
$d = dir (http://php.net/dir)('freebies');
echo "Directory: " . $d->path . "<br>";
while (false !== ($entry = $d->read())) {
echo "<a href='/freebies/".$entry."'>".$entry."</a><br>";
}
$d->close();
?]

View 4 Replies View Related

Listing Files In Directory

Dec 6, 2003

The script is a basic file lister. The code is placed 12 times in an index.php file to create a sitemap for the main directory. This is one section (of the 12):

echo "<dl><dt><b>Jan 2003</b></dt><dd><table border=&#390;'><tr>";
$jandir="jan2003/";
$jan=opendir($jandir);
while($janb=readdir($jan))
{
$janc = $janb;
$janb = str_replace(".","",$janb);
$janb = str_replace("..","",$janb);
$janb = str_replace("week"," Week ",$janb);
echo "<td><a href=$jandir$janc>$janb</a></td>";
}
closedir($jan);
echo "</tr></table></dd></dl>";

I've yet to figure out why 'dots' are listed as files if I remove the string replace lines.

View 1 Replies View Related

Directory Listing Of Any Website ?

Apr 7, 2011

One of my professors said something vague about how you could use a PHP script to list all the files that are in the same directory as some particular web page.I've been trying to figure out how to do this but have had no luck... The only solutions I could figure out were using file handling functions, but whatever I came up with only worked on local directories.

I get that this might not be possible on most websites because of security reasons, but then there's a lot that I don't know about PHP so I thought I could ask here. What would I have to use to do it?

View 3 Replies View Related

Listing Files In A Directory?

May 3, 2011

I have the following piece of PHP code to retrieve a list of files on a directory, and then build links to each file:

<?php
$dir=""; // Directory where files are stored
if ($dir_list = opendir($dir)){
while(($filename = readdir($dir_list)) !== false){
?>
<li><a href="<?php echo $filename; ?>"><?php echo $filename;
?></a></li>

[Code]...

it is all nice and fine, but it builds two links too many. the first link leads to the folder where the php file resides, and the second link leads to the folder that contains the folder where the php file resides. I was wondering if there is a way, other than putting an if statement inside my while loop, to have php only generate links for the files on the directory I wish, excluding the other two links.

View 1 Replies View Related

Stop Listing Of Directory Using Url?

Feb 3, 2010

How can I stop the web visitors ,if they are trying to display the folder content ,using URL

View 10 Replies View Related

Listing All Images In A Directory ?

Sep 17, 2010

I have the code below that lists all the images in a folder, the problem is that it finds some files ( a . and a ..) that I am not sure what they are so I am not sure how to prevent them from showing up. I am on a windows XP machine,

Errors:
Warning: rename(images/.,images/.) [function.rename]: No error in C:wampwwwTestinglistPhotosA.php on line 14

Warning: rename(images/..,images/..) [function.rename]: No error in C:wampwwwTestinglistPhotosA.php on line 14

Code:

<?php
define('IMAGEPATH', 'images/');
if (is_dir(IMAGEPATH)){
$handle = opendir(IMAGEPATH);[code]....

View 3 Replies View Related

ADVERTISEMENT