Voting

: max(seven, six)?
(Example: nine)

The Note You're Voting On

Anonymous
3 years ago
Note that the order of the keys in the returned array is the same as the order of the keys in the source array.

To sort by the second array, then you may do so through array_replace.

<?php
$array
= array(
'two' => 'a',
'three' => 'b',
'one' => 'c',
);

$keyswant = array(
'one' => '',
'three' => '',
);

print_r(array_intersect_key(array_replace($keyswant, $array), $keyswant));

?>

Shows:

Array
(
[one] => c
[three] => b
)

Rather than:

Array
(
[three] => b
[one] => c
)

<< Back to user notes page

To Top