Jump to content

Need to sort a literal array


loganbest

Recommended Posts

I have a bunch of PDF's, some of them having Uppercase first letters and some having lowercase first letters. Right now my code is alphabetizing all of the Uppercase first letters first then all of the lowercase. I want them to be mixed.

 

$dir = "../../forms/pdf/";
foreach(glob($dir.'*.pdf') as $pdf){
    $files[] = str_replace($dir, '', $pdf);
}

 

then:

<select name="current_pdf" id="current_pdf">
            <option value="">Please Select a PDF to replace</option>
            <?php
            foreach($files as $file) {
                echo "<option value=\"$file\">" . $file . "</option>";
            }
            ?>
            </select>

Link to comment
Share on other sites

<?php 
$dir = "../../forms/pdf/";
foreach(glob($dir.'*.pdf') as $pdf){
    $files[] = str_replace($dir, '', $pdf);
}
$files = natcasesort($files);

?>

This does not populate the select box.

 

<?php 
$dir = "../../forms/pdf/";
foreach(glob($dir.'*.pdf') as $pdf){
    $files[] = str_replace($dir, '', $pdf);
}
$files[] = natcasesort($files[]);

?>

This produces this error:

Warning: natcasesort() [function.natcasesort]: The argument should be an array in /site_homes/www08/intra/pdf-upload/index2.php on line 6

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.