Re: [PHP] Sort question..
On Wed, Apr 25, 2012 at 3:16 PM, Karl-Arne Gjersøyen wrote: > Hello again. > I have a photo album that show all images in a specified directory. > but I like to sort them by filename as one possibillity and random > sort the photos as another feature. > I don't know how to do this.. Here is my soruce-code: > > > > > > Bildegalleri > > > > Bildegalleri > Last opp nye bilder | > Sorter på filnavn > | > Tilfeldig > sortering > > // Skann katalogen og hent fram bildene > $bilde = new DirectoryIterator('bilder/'); > while($bilde->valid()){ > if(!$bilde->isDot()){ > if($_GET['sorter_filnavn']){ > echo ' src="bilder/'.sort($bilde->getFilename()).'" > alt="'.sort($bilde->getFilename()).'" height="200">'; > } elseif($_GET['tilfeldig_sortering']) { > echo ' src="bilder/'.rand($bilde->getFilename()).'" > alt="'.rand($bilde->getFilename()).'" height="200">'; > } else { > echo ' src="bilder/'.$bilde->getFilename().'" > alt="'.$bilde->getFilename().'" height="200">'; > } > } > $bilde->next(); > } > unset($bilde); > ?> > > > > > I will be lucky if somebode have time to help me out here.. I am sure > it is some functions in php that can do the trick, but haven't found > anything yet. > Thanks for your time. > > Karl Put all the files in an array, then sort with one of the sort functions[1]. - Matijn [1] http://www.php.net/manual/en/array.sorting.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Sort question..
Hello again. I have a photo album that show all images in a specified directory. but I like to sort them by filename as one possibillity and random sort the photos as another feature. I don't know how to do this.. Here is my soruce-code: Bildegalleri Bildegalleri Last opp nye bilder | Sorter på filnavn | Tilfeldig sortering valid()){ if(!$bilde->isDot()){ if($_GET['sorter_filnavn']){ echo ''; } elseif($_GET['tilfeldig_sortering']) { echo ''; } else { echo ''; } } $bilde->next(); } unset($bilde); ?> I will be lucky if somebode have time to help me out here.. I am sure it is some functions in php that can do the trick, but haven't found anything yet. Thanks for your time. Karl -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Sort Question (Again)
This didn't get answered before. I'm trying to sort an array but it won't work. $list = file('list_main.txt'); $list = sort($list); If I print $list it gives me 1 and print $list[0] is nothing. The list_main.txt looks something like this: ABC DEFG HIJ etc. Jeff Oien -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Sort Question
Could someone tell me how to sort this? Each $variable1 is a 3,4 or 5 letter string that I would like sorted alphabetically. I assumed "sort" would do it but apparently it isn't the right type of array. Thanks. $variable1 = split("\n", $variable); Jeff Oien -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Sort Question
> I am doing a dir list of an ftp and using sort to sort the dir list > alphabetically. What I am using now sorts it alphabetically but it sorts > the capital letters then the lower case so a capital "Z" would come before a > lower case "a" > > The Code I am using is: > > sort($complete_list); > return $complete_list; > > Does someone know how I can sort an array alphabetically with the case > insensitive sort? usort($complete_list, 'strcasecmp'); http://php.net/manual/en/function.usort.php http://php.net/manual/en/function.strcasecmp.php -- WARNING [EMAIL PROTECTED] address is not working -- Use [EMAIL PROTECTED] Wanna help me out? Like Music? Buy a CD: http://l-i-e.com/artists.htm Volunteer a little time: http://chatmusic.com/volunteer.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Sort Question
Hello, I am doing a dir list of an ftp and using sort to sort the dir list alphabetically. What I am using now sorts it alphabetically but it sorts the capital letters then the lower case so a capital "Z" would come before a lower case "a" The Code I am using is: sort($complete_list); return $complete_list; Does someone know how I can sort an array alphabetically with the case insensitive sort? Thank You Brandon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]