Answer the question
In order to leave comments, you need to log in
How to compare and sort two arrays in php?
Good afternoon.
Let's say there is an array:
Array (
[0] => p
[1] => s
[2] => b
[3] => a
)
and a second array (sorted alphabetically):
Array (
[0] => a
[ 1] => b
[2] => p
[3] => s
)
How can we compare both arrays and sort the second one so that we get a "fish" while preserving the keys? Example:
Array (
[2] => p
[3] => s
[1] => b
[0] => a
)
Instead of the first array, you can use a regular string ("fish").
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question