TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 12-20-2007, 03:34 AM   #1 (permalink)
Orc
The Prestige
 
Orc's Avatar
 
Join Date: Dec 2007
Posts: 1,044
Thanks: 193
Orc is on a distinguished road
Default How do you set a List in Alphabetical Order?

Such as a long list of things?
Orc is offline  
Reply With Quote
Old 12-20-2007, 03:46 AM   #2 (permalink)
Wizard
Top Contributor 
 
Village Idiot's Avatar
 
Join Date: Sep 2007
Posts: 1,299
Thanks: 17
Village Idiot is on a distinguished road
Default

What is your data source?
__________________

Village Idiot is offline  
Reply With Quote
Old 12-20-2007, 03:49 AM   #3 (permalink)
The Frequenter
 
Join Date: Dec 2007
Location: In my basement
Posts: 386
Thanks: 47
Aaron is on a distinguished road
Default

Something like this might work...
$var = strtolower($var);
if (isset($vars[$var])) {
$vars[$var]++;
} else {
$vars[$var] = 1;
}



buuuuut, I think this would be a built in function... Lemme check the documentation.


edit: Yeah, look here for some nice information... I think...

http://nl3.php.net/manual/hu/function.strcmp.php
Send a message via MSN to Aaron
Aaron is offline  
Reply With Quote
Old 12-20-2007, 03:49 AM   #4 (permalink)
Orc
The Prestige
 
Orc's Avatar
 
Join Date: Dec 2007
Posts: 1,044
Thanks: 193
Orc is on a distinguished road
Default

Quote:
Originally Posted by Village Idiot View Post
What is your data source?
You mean my source? or just..? I want to use strings, not arrays!
Orc is offline  
Reply With Quote
Old 12-20-2007, 03:50 AM   #5 (permalink)
Wizard
Top Contributor 
 
Village Idiot's Avatar
 
Join Date: Sep 2007
Posts: 1,299
Thanks: 17
Village Idiot is on a distinguished road
Default

Is it a collection of strings in an array? Is it from a mysql database?
__________________

Village Idiot is offline  
Reply With Quote
Old 12-20-2007, 03:51 AM   #6 (permalink)
Orc
The Prestige
 
Orc's Avatar
 
Join Date: Dec 2007
Posts: 1,044
Thanks: 193
Orc is on a distinguished road
Default

Quote:
Originally Posted by Village Idiot View Post
Is it a collection of strings in an array? Is it from a mysql database?
No, it's a directory script. using the Dir class.
Orc is offline  
Reply With Quote
Old 12-20-2007, 03:54 AM   #7 (permalink)
Wizard
Top Contributor 
 
Village Idiot's Avatar
 
Join Date: Sep 2007
Posts: 1,299
Thanks: 17
Village Idiot is on a distinguished road
Default

But how are the strings stored? I cant help you until I know that.
__________________

Village Idiot is offline  
Reply With Quote
Old 12-20-2007, 03:59 AM   #8 (permalink)
Orc
The Prestige
 
Orc's Avatar
 
Join Date: Dec 2007
Posts: 1,044
Thanks: 193
Orc is on a distinguished road
Default

Quote:
Originally Posted by Village Idiot View Post
But how are the strings stored? I cant help you until I know that.
PHP Code:
<?php 

$dir 
dir$d );
  while( 
false !== ( $entry $dir->read() ) ) {
if(
$entry!='.' && $entry!='..' && $entry!='index.php' && $entry!='error_log') {



   echo 
'<b><a style="color:red;font-family:helvetica;font-size:12px;" href="'.$entry.'">';
   print 
$entry.'<br/>';
   echo 
'</a></b>';

 }
}



     

?>
Orc is offline  
Reply With Quote
Old 12-20-2007, 04:11 AM   #9 (permalink)
Wizard
Top Contributor 
 
Village Idiot's Avatar
 
Join Date: Sep 2007
Posts: 1,299
Thanks: 17
Village Idiot is on a distinguished road
Default

Something like this
PHP Code:
 <?php  

$dir 
dir$d ); 
  while( 
false !== ( $entry $dir->read() ) ) { 
if(
$entry!='.' && $entry!='..' && $entry!='index.php' && $entry!='error_log') { 



$arr[] = $entry;

 } 


sort($arr); //making your own bubble sort method will be faster, but I cant find mine
foreach($arr as $val)
{
echo 
$val;
}


      

?>
__________________

Village Idiot is offline  
Reply With Quote
The Following User Says Thank You to Village Idiot For This Useful Post:
Orc (12-20-2007)
Old 12-20-2007, 04:41 AM   #10 (permalink)
Orc
The Prestige
 
Orc's Avatar
 
Join Date: Dec 2007
Posts: 1,044
Thanks: 193
Orc is on a distinguished road
Default

Quote:
Originally Posted by Village Idiot View Post
Something like this
PHP Code:
 <?php  

$dir 
dir$d ); 
  while( 
false !== ( $entry $dir->read() ) ) { 
if(
$entry!='.' && $entry!='..' && $entry!='index.php' && $entry!='error_log') { 



$arr[] = $entry;

 } 


sort($arr); //making your own bubble sort method will be faster, but I cant find mine
foreach($arr as $val)
{
echo 
$val;
}


      

?>
Okay I just tried that and I got
Code:
Parse error: syntax error, unexpected ')' in index.php on line 47
Orc is offline  
Reply With Quote
Old 12-20-2007, 04:43 AM   #11 (permalink)
Wizard
Top Contributor 
 
Village Idiot's Avatar
 
Join Date: Sep 2007
Posts: 1,299
Thanks: 17
Village Idiot is on a distinguished road
Default

Whats line 47. I have to go now, il be back tomorrow afternoon
__________________

Village Idiot is offline  
Reply With Quote
Old 12-20-2007, 04:46 AM   #12 (permalink)
Orc
The Prestige
 
Orc's Avatar
 
Join Date: Dec 2007
Posts: 1,044
Thanks: 193
Orc is on a distinguished road
Default

Quote:
Originally Posted by Village Idiot View Post
Whats line 47. I have to go now, il be back tomorrow afternoon
-snip- Nevermind I think I got it, my mistake! >.<
Orc is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 04:15 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design