Re: [PHP] usort e é together

2004-07-11 Thread Marek Kilimajer
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[lt;--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 trtdnbsp;/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 tdnbsp;/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
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] parse error: [PHP] usort e é together

2004-07-11 Thread John Taylor-Johnston
I went with this, but am getting a parse error.

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);'));

Anyone see it? I've got headaches from squinting at the monitor.

Thanks,
J

Marek Kilimajer wrote:

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);'));

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



Re: [PHP] parse error: [PHP] usort e é together

2004-07-11 Thread Marek Kilimajer
I'm sorry, I used unescaped single quotes inside single quoted string, 
this is right:

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);'));
John Taylor-Johnston wrote:
I went with this, but am getting a parse error.
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);'));
Anyone see it? I've got headaches from squinting at the monitor.
Thanks,
J
Marek Kilimajer wrote:

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);'));

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


Re: [PHP] parse error: [PHP] usort e é together

2004-07-11 Thread John Taylor-Johnston
Sorry. Still getting a 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);'));

Can you have two arrays there? http://ca2.php.net/manual/en/function.str-replace.php

All the brackets are in the right place. Hmmm ...?

Thanks,
John

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



Re: [PHP] parse error: [PHP] usort e é together

2004-07-11 Thread Miroslav Hudak (php/ml)
Dunno the original question, but this obviously should be escaped...
So the correct code follows...
usort($authors, create_function('$a,$b','
  $a = str_replace(array(\'é\', \'a\'), array(\'e\', \'a\'), $a);
  $b = str_replace(array(\'é\', \'a\'), array(\'e\', \'a\'), $b);
  return strcasecmp($a,$b);'));
Regards,
m.
John Taylor-Johnston wrote:
Sorry. Still getting a 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);'));
Can you have two arrays there? http://ca2.php.net/manual/en/function.str-replace.php
All the brackets are in the right place. Hmmm ...?
Thanks,
John
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] usort e é together

2004-07-11 Thread John Taylor-Johnston
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 trtd
Note: A star, \*\, indicates that the author uses a pseudonym.brNoter : 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[lt;--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\tdnbsp;/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 tdnbsp;/td;
  echo /tr\n;
 }
}

mysql_close($myconnection);
##
echo /table
/td
/tr\n;

?

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



Re: [PHP] usort e é together

2004-07-11 Thread Miroslav Hudak (php/ml)
this is slightly changed function of yours, written for better 
readability...

?php
$authors = array('élen', 'Élen', 'Elison', 'ámadeus', 'albert', 
'alfred', 'amadeus', 'elen');

function usort_callback($a, $b) {
$a = strtolower($a); $b = strtolower($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);
?
it does diacritics safe and case-insensitive sort of authors... at least 
on my workstation... is it what you need? while i don't have your 
original problem, i just can guess... hope it helps.

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 trtd
Note: A star, \*\, indicates that the author uses a pseudonym.brNoter : 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[lt;--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\tdnbsp;/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 tdnbsp;/td;
  echo /tr\n;
 }
}
mysql_close($myconnection);
##
echo /table
/td
/tr\n;
?
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] usort e é together

2004-07-11 Thread Miroslav Hudak (php/ml)
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 trtd
Note: A star, \*\, indicates that the author uses a pseudonym.brNoter : 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[lt;--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\tdnbsp;/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 tdnbsp;/td;
  echo /tr\n;
 }
}
mysql_close($myconnection);
##
echo /table
/td
/tr\n;
?
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] usort e é together

2004-07-11 Thread John Taylor-Johnston
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 trtd
  Note: A star, \*\, indicates that the author uses a pseudonym.brNoter : 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[lt;--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\tdnbsp;/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 tdnbsp;/td;
echo /tr\n;
   }
  }
 
  mysql_close($myconnection);
  ##
  echo /table
  /td
  /tr\n;
 
  ?
 



Re: [PHP] usort e é together

2004-07-11 Thread John Taylor-Johnston
Sorry, doesn't work either.

http://compcanlit.usherbrooke.ca/new1/db/index.php?ausenquiry=e
does not contain those that start with é:
http://compcanlit.usherbrooke.ca/new1/db/index.php?ausenquiry=é

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);

I'll leave var_dump in there for verification.

?php

if(!$ausenquiry) $ausenquiry =a;

echo trtd
Note: A star, \*\, indicates that the author uses a pseudonym.brNoter : 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', 'E');
#
#usort($authors, create_function('$a,$b','
#$a = str_replace($first, $second, $a);
#$b = str_replace($first, $second, $b);
#return strcasecmp($a,$b);'));

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);


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[lt;--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\tdnbsp;/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 tdnbsp;/td;
  echo /tr\n;
 }
}

mysql_close($myconnection);
##
echo /table
/td
/tr\n;

?

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



[PHP] usort e é together

2004-07-10 Thread John Taylor-Johnston
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);'));

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[lt;--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 trtdnbsp;/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 tdnbsp;/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

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