/**
* Sorts one array using a second as a guide
*
* @param array $array Array to be sorted
* @param array $order_array Guide array
*
* @return array $ordered Sorted array
*/
private function sort_array( $array, $order_array) {
$ordered = array();
foreach ( $order_array as $key ) {
if ( array_key_exists( $key, $array ) ) {
$ordered[ $key ] = $array[ $key ];
unset( $array[ $key ] );
}
}
return $ordered + $array;
}
Sorts an associative array by it's keys using another indexed array as a guide.
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.