Skip to content

Instantly share code, notes, and snippets.

@Mte90
Last active May 22, 2017 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Mte90/e61e7be6265196a07ac0420f68ab79d2 to your computer and use it in GitHub Desktop.
Save Mte90/e61e7be6265196a07ac0420f68ab79d2 to your computer and use it in GitHub Desktop.
Order array multidimensional using a reference array
<?php
function sortArrayByArray( $array, $orderArray ) {
$order = array();
foreach ( array_keys( $array ) as $index ) {
foreach ( array_keys( $orderArray ) as $key ) {
$order[ $index ][ $key ] = $array[ $index ][ $key ];
}
}
return $order;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment