<?php $data = array( "item1"=>"1", "item2"=>"3", "item3"=>"5", "item4"=>"2", "item5"=>"4" ); $sortingArr = array("5","4","3","2","1"); uasort($data, function($a, $b) use ($sortingArr) { return array_search($a, $sortingArr) <=> array_search($b, $sortingArr); }); print_r($data);
You have javascript disabled. You will not be able to edit any code.