Комментарии:
The best video for multidimensional array sorting by so far.
Bless you!
Gracias 😁
ОтветитьThis is by far one of the most comprehensible and easy to understand videos that I've seen on this. And trust me, i've watched a lot over the past two days. Thank you.
Ответитьohh man...i know this is an old video, but still THANK YOU!!!! you saved me lots of headache!!!! Cheers!!!
ОтветитьThank you so much, my friend. You have saved me a lot of headaches!
ОтветитьThank you, that is exactly what i was looking for - for hours!
ОтветитьThank you so much! I had to make slight tweak since numeric indices surfaced 'offset' errors. This is the tweak - just in case someone is running into the same issue: $b[$k] and $c[$k].
Ответитьthis works great ... issue is it doesnt work with dates... because it will only look at the first number in the date.
ОтветитьVery good tutorial! I could hear it well and clear, on topic the entire time and well thought out.
ОтветитьThank you, so much... This simple function help me a lot...
ОтветитьObrigado, very good!
Ответитьgreat!!!
ОтветитьThank you very much!
GOD bless you.
Pleas read more about array_multisort.
This is the fragment of code that I write when I needed to sort multidemensional array:
<?php
$arr = [
['lname' => 'Allower', 'fname' => 'Stewart', 'profesion' => 'cheef'],
['lname' => 'Kovalski', 'fname' => 'John', 'profesion' => 'programmist'],
['fname' => 'Savige', 'fname' => 'Allan', 'profesion' => 'accounter']
];
foreach($arr as $key => $val)
{
$lname[$key] = $val['lname'];
$fname[$key] = $val['fname'];
$profesion[$key] = $val['profesion'];
}
array_multisort($lname, SORT_DESC, $fname, SORT_ASC, $arr );
echo '<pre>';
var_dump($arr);
echo '</pre>';
Explenations:
In array_multisort you can set numbers of arrays to sort asc or desc as a column.
In last parameter you set the name of original array that you want to sort.
Important think is that the names of arrays shuld be the same that the collumn of multidemesional array.
So what is the point of building another function in script if you got build-in ready to use function?
You are awesome. Thanks.
Ответитьfont size is very short...
ОтветитьHaha thanks!
ОтветитьNo problem!
Ответить