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);
}
?>

View 14 Replies


ADVERTISEMENT

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

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

ORDER BY Timestamp Listing In Wrong Order?

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

Reverse Order Of XML?

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

Reverse Order

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

Reverse Order - Last Record

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

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

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

Reading A File In Reverse Order

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

Fopen Reverse/limit Order

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

Output A Date In Reverse Order

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

Reverse The Order When Echoing Results?

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

Session Var Is Assigned In Reverse Order?

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

Blogger Reverse Post Order

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

Show The First 30 Records In Reverse Order

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

Reverse File Upload Order

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

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

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

Reverse Order On Output Of Custom Values

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

Sort An Array In Reverse Order Of Values?

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

Gallery Thumbs Are Not Showing In Reverse Order?

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

Sorting Files In Reverse Alphabetical Order

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

Recursively Retrieve The Directory Listing Of A Given Directory?

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

File Listing In Alphabetical Order?

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

Excluding A Directory From A Web Directory Listing?

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

Directory Listing ...

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

Directory(ONLY) Listing

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

Php Listing A Directory?

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







Copyrights 2005-15 www.BigResource.com, All rights reserved