如何爆炸键值对并在查询中使用它们

in my laravel project i have a db field in which user can store the parameters that to be considered for sorting and also their orders. That is, the data table "config" contains a column value like this

status-desc,priority-asc,..etc

In here, when i write the query i need to use these values as the order by pairs.

ORDER BY status desc, priority asc

I can hard code this in the query code like the above because the sorting columns can be different based on the users entry.

i already exploded two criteria separately like this

$params = explode(',', $sort_param->config_value);

so that i got $params[0] = status-desc and $params[1] = priority-asc ...

But how can i again explode these and fetch and use them in the query for order by??

what i did so far is:

$countt = count($params);
for($prm=0;$prm<$countt;$prm++){
list($k, $v) = explode('-', $params[$prm]);
}
 echo $k.' '.$v;

The echo $k and $v displays priority asc

Try

$tab = 'status-desc,priority-asc,value,string,demo';
$params = explode(',',$tab);
foreach($params as $v){
    $tab2[] = explode('-',$v);


}
$newTab = array_merge($params,$tab2);
print_r($newTab);

Try with this simple code

$tab = 'status-desc,priority-asc,value,string,demo';
list($statut,$priority,$value,$demo) = explode(',',$tab);
echo $statut ;