I have this array:
$routes = array(
array(
\'code\' => \'PZSA\',
\'name\' => \'PLaza san antonio\',
),
array(
\'code\' => \'AVAD\
Rather than doing what is essentially a linear search for each element, it might be quickest to re-index your original array by code:
// create the index
$indexed = array();
foreach($routes as $route) {
$indexed[$route['code']] = $route;
}
// add each target to a new sorted array in order
$sorted = array();
foreach($target as $code) {
$sorted[] = $indexed[$code];
}