I would do it this way (it fails if some names are same):

Chad Winger wrote:

>Hello Rudolf,
>Thank you for responding to my post, I really appreciate it.
>
>I ran the script you sent me, and then I tried looking up the syntax to try
>to figure out what it means. As it would be pointless for me just to take
>suggestions that people send me and then not learn what they mean. The
>resulkt of your code does in fact alphabatize the teams in the select list,
>however there is a little problem with the end result.
>
>your code:
>
><?php
>
>  include ("C:\Program
>Files\EasyPHP\www\florentiaviola.com\control\config.php");
>  
>
>  $fd = fopen ($teams, "r");
>  while (!feof ($fd))
>  {
>   $list = fgets($fd, 4096);
>   $squads = explode("|", $list);
>   $alphabetical[$squads[1]] = $squads[0];
>  }
>   fclose ($fd);
>
>   ksort ($alphabetical);
>  
>
>   foreach ($alphabetical as $name => $id)
>   {
>   echo '<OPTION VALUE="'.$id.'">'.$name.'</OPTION>'."\n";
>   }
>
>
>
>?>
>
>returns the follwoing html:
><OPTION VALUE="A">Aglianese</OPTION>
><OPTION VALUE="B">Brescello</OPTION>
><OPTION VALUE="C">Casteldisangro</OPTION>
><OPTION VALUE="C">Castelnuovo</OPTION>
><OPTION VALUE="F">Fano</OPTION>
><OPTION VALUE="F">Florentia Viola</OPTION>
><OPTION VALUE="F">Forlě</OPTION>
><OPTION VALUE="G">Grosseto</OPTION>
><OPTION VALUE="G">Gualdo</OPTION>
>
>
>It is returning the first letter of $squads[1]. so the "id variable is
>getting lost.That variable is $squads[0]. So in effect that vairable is
>getting "lost" because when i modify the line
>
>echo '<OPTION VALUE="'.
>$alphabetical[$i][0].'">'.$alphabetical[$i].'</OPTION>'."\n";
>
>to read
>
>echo '<OPTION VALUE="'. $squads[0].'">'.$alphabetical[$i].'</OPTION>'."\n";
>
>then the HTML output becomes
>
><OPTION VALUE="19">Aglianese</OPTION>
><OPTION VALUE="19">Brescello</OPTION>
><OPTION VALUE="19">Casteldisangro</OPTION>
><OPTION VALUE="19">Castelnuovo</OPTION>
><OPTION VALUE="19">Fano</OPTION>
><OPTION VALUE="19">Florentia Viola</OPTION>
><OPTION VALUE="19">Forlě</OPTION>
><OPTION VALUE="19">Grosseto</OPTION>
><OPTION VALUE="19">Gualdo</OPTION>
>
>In other words what I am trying to do is something to the effect of
>$alphabetical = $squads[1][0]. Then I want to sort that only by $squads[1].
>When the html is returned, I want to be able to echo the $squads[0] as the
>Value of the select dropdown.
>
>Thanks again,
>-Tree
>
>
>  
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to