Thanks!
What does var_dump do? (I didn't really understand the manual.)
"Miroslav Hudak (php/ml)" wrote:
> Pardon me for the strtolower line, i've just forgot there... it's 4:30AM
> here in Slovakia... :/
>
> correct listing follows...
>
> <?php
> $authors = array('�len', '�len', 'Elison', '�madeus', 'albert',
> 'alfred', 'amadeus', 'elen');
>
> function usort_callback($a, $b) {
> $a = str_replace(array('�', '�'), array('a', 'e'), strtolower($a));
> $b = str_replace(array('�', '�'), array('a', 'e'), strtolower($b));
> return (strcmp($a, $b));
> }
>
> usort($authors, 'usort_callback');
>
> var_dump($authors);
> ?>
>
> regards,
> m.
>
> John Taylor-Johnston wrote:
>
> > http://compcanlit.usherbrooke.ca/new1/db/index.php?ausenquiry=e
> > http://compcanlit.usherbrooke.ca/new1/db/index.php?ausenquiry=�
> >
> > It still sorts "�" and "e" separately, but without a parse error:
> >
> > $first = array('�', '�');
> > $second = array('a', 'e');
> >
> > usort($authors, create_function('$a,$b','
> > $a = str_replace($first, $second, $a);
> > $b = str_replace($first, $second, $b);
> > return strcasecmp($a,$b);'));
> >
> > Back to the drawing board? I tried this too:
> >
> > $first = array('�', '�', '�', '�');
> > $second = array('a', 'e', 'A', '�');
> >
> > Ideas? Thanks,
> > John
> >
> >
> >
> >>Parse error on line 40:
> >>
> >>39> usort($authors, create_function('$a,$b','
> >>40> $a = str_replace(array('�', '�'), array('e', 'a'), $a);
> >>41> $b = str_replace(array('�', '�'), array('e', 'a'), $b);
> >>42> return strcasecmp($a,$b);'));
> >
> >
> > <?php
> >
> > if(!$ausenquiry) $ausenquiry ="a";
> >
> > echo "<tr><td>
> > Note: A star, \"*\", indicates that the author uses a pseudonym.<br>Noter : Une
> > �toile, \"*\", indique que cet auteur est connu par un nom de plume.
> >
> > <table border=\"0\" cellspacing=\"0\" cellpadding=\"5\">\n";
> >
> >
> > ######################################################
> > $myconnection = mysql_connect($server,$user,$pass);
> > mysql_select_db($db,$myconnection);
> >
> > $news = mysql_query("select id,AUS from $table");
> >
> > ######################################################
> > $authors = array();
> > $author_list = array();
> >
> > while ($mydata = mysql_fetch_object($news))
> > {
> > $mydata->AUS = str_replace(" ;", ";", $mydata->AUS);
> > $mydata->AUS = str_replace("; ", ";", $mydata->AUS);
> > $tempauthors = explode(";", $mydata->AUS);
> > foreach ($tempauthors as $singleauthor)
> > {
> > if ($singleauthor <> "")
> > {
> > array_push($authors, $singleauthor);
> > $author_list[$singleauthor][] = $mydata->id; // use an associative array...
> > }
> > }
> > }
> >
> > #sort($authors);
> > #usort($authors, create_function('$a,$b','return strcasecmp($a,$b);'));
> >
> > #usort($authors, create_function('$a,$b','
> > # $a = str_replace(array('�', '�'), array('e', 'a'), $a);
> > # $b = str_replace(array('�', '�'), array('e', 'a'), $b);
> > # return strcasecmp($a,$b);'));
> >
> > $first = array('�', '�', '�', '�');
> > $second = array('a', 'e', 'A', '�');
> >
> > usort($authors, create_function('$a,$b','
> > $a = str_replace($first, $second, $a);
> > $b = str_replace($first, $second, $b);
> > return strcasecmp($a,$b);'));
> >
> >
> > foreach (array_count_values ($authors) as $author=>$count)
> > {
> >
> > if((strtolower(substr($author, 0, 1)) == $ausenquiry))
> > {
> >
> > echo "<tr bgcolor=\"#D3DCE3\">";
> > echo "<th align=\"left\" colspan=\"2\"><a
> > href=\"".$SCRIPT_NAME."?searchenquiry=".urlencode($author)."\">".$author."</a>
> > <small>[<--Search Entire Database]</small></th>";
> > echo "<th align=\"right\" width=\"5%\" nowrap>(".$count." ";
> > if($count > 1)
> > {echo "records found/trouv�s)";}
> > else{echo "record found/trouv�)";}
> > echo"</th></tr>\n";
> >
> > echo "<tr bgcolor=\"#F5F5F5\"><td> </td>";
> > echo "<td align=\"left\">";
> > $temp = "";
> > foreach ($author_list[$author] as $ausid)
> > {
> > $temp .= "<a target=\"printwindow\"
> > href=\"print.php?id=".urlencode($ausid)."\">".$ausid."</a>, ";
> > }
> > $temp = substr("$temp", 0, -2);
> > echo "$temp</td>";
> > echo "<td> </td>";
> > echo "</tr>\n";
> > }
> > }
> >
> > mysql_close($myconnection);
> > ######################################################
> > echo "</table>
> > </td>
> > </tr>\n";
> >
> > ?>
> >