array_multisort and dynamic variable options.
Posted
by websiteguru
on Stack Overflow
See other posts from Stack Overflow
or by websiteguru
Published on 2010-03-19T02:55:45Z
Indexed on
2010/03/19
3:01 UTC
Read the original article
Hit count: 150
php
Im trying to sort any array with array_multisort and everything is working great. However, based on conditions in my script, I need to change the options. So What I have so far is this:
array_multisort(
$sort1,SORT_ASC,
$sort2,SORT_ASC,
$sort3,SORT_ASC,
$arraytosort
);
and what I would like to have is something like this:
$dynamicSort = "$sort1,SORT_ASC,$sort2,SORT_ASC,$sort3,SORT_ASC,";
array_multisort(
$dynamicSort,
$arraytosort
);
Any suggestions?
© Stack Overflow or respective owner