Re: usort e & é together
| From: | Marek Kilimajer | Date: | Sun, 11 Jul 2004 09:06:36 +0000 |
| Subject: | Re: usort e & é together | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-190175@lists.php.net to get a copy of this message | ||
John Taylor-Johnston wrote:
I think my problem lies in usort. I have a big honker of an array which I usort.
$ausenquiry = "e";
and
$ausenquiry = "e";
give a separate result.
I want to conjoin them. Possible? The same would be true for "a" and "à".
usort distinguishes between é and e. Any way around this? I don't see any inspiration: http://ca2.php.net/manual/en/function.usort.php
John
-------snip----------
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...
}
}
}
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);'));
foreach (array_count_values ($authors) as $author=>$count) { if((strtolower(substr($author, 0, 1)) == $ausenquiry)) { echo "<tr>"; 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><td> </td>"; echo "<td align=\"left\">"; $temp = ""; foreach ($author_list[$author] as $ausid) { $temp .= "<a target=\"printwindow\" href=\"".$SCRIPT_NAME."?id=".urlencode($ausid)."&searchenquiry=".urlencode($author)."\">".$ausid."</a>, "; } $temp = substr("$temp", 0, -2); echo "$temp</td>"; echo "<td> </td>"; echo "</tr>\n"; } } -- John Taylor-Johnston ----------------------------------------------------------------------------- "If it's not open-source, it's Murphy's Law." ' ' ' Collège de Sherbrooke: ô¿ô http://www.collegesherbrooke.qc.ca/languesmodernes/- Université de Sherbrooke: http://compcanlit.ca/ 819-569-2064