* Thus wrote 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.

For Starters, you're trying to do everything in the world to one
function call.

Break it down and format it into a human readable thing.

$func_args = '$a, $b';
$func_code = '
 static $replace = array('é', 'à');
 static $with    = array('e', 'a');

 $a = str_replace($replace, $with, $a);
 $b = str_replace($replace, $with, $b);

 return strcasecmp($a, $b);
';

usort($authors, create_function($func_args, $func_code));

The question does occure to me why you're using a create_function()
call instead of simply defining a function to used for usort().

Oh, and strtr() might be more of an appropriate choice:

  $translate = array('éà', 'ea');

  $a = strtr($a, $translate);
  $b = strtr($b, $translate);



Curt
-- 
First, let me assure you that this is not one of those shady pyramid schemes
you've been hearing about.  No, sir.  Our model is the trapezoid!

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

Reply via email to