Re: sorting in PHP.
..oO(amit)
>Thanks indeed for you solution using regular experession but I'm
>afraid to get into trouble later since I'm not familiar with RE yet.
>
>Any other suggestions?
Here's another one:
The strings look like CSV, so you could try to split them. Currently PHP
can only read CSV data from files, but in coming PHP versions there will
be a function to parse CSV strings. For now you could use this hackish
replacement until the official str_getcsv() becomes available:
if (!function_exists('str_getcsv')) {
function str_getcsv($input, $delimiter = ',', $enclosure = '"',
$escape = '\\') {
$fh = fopen('php://memory', 'w+');
fwrite($fh, $input);
rewind($fh);
$result = fgetcsv($fh, 0, $delimiter, $enclosure);
fclose($fh);
return $result;
}
}
With this function you can easily split your data strings and should be
able to use usort() to sort them on the 10th item.
HTH
Micha
|