Determine position changes between two arrays I have two arrays
$array1 = ["name1","name2","name3","name4"];
$array2 = ["name2","name1","name3","name4"];

What I would like to know is the position changes between the arrays. In the above example the output will be:
$returnArray = [
    "name2"=>"up",
    "name1"=>"down",
    "name3"=>"same",
    "name4"=>"same"
];

up = moved position up
down = moved position down
same = stayed on the same position
What is the quickest way to determine the position changes comparing the two arrays?

This should work for you:
Just loop through all unique values of $array1 and check with array_search()
 if the value is at the same position, down or up.
<?php

    $array1 = ["name1","name2","name3","name4"];
    $array2 = ["name2","name1","name3","name4"];
    $result = [];

    foreach(array_unique($array1) as $k => $v){
$result[$v] = $k == array_search($v, $array2) ? "same" : ($k < array_search($v, $array2) ? "up": "down");
    }

    print_r($result);

?>

And in PHP 7 just use the spaceship operator, e.g.
<?php

    $array1 = ["name1","name2","name3","name4"];
    $array2 = ["name2","name1","name3","name4"];
    $arr = ["-1" => "down", "0" => "same", "1" => "up"];
    $result = [];

    foreach(array_unique($array1) as $k => $v){
$result[$v] = $arr[array_search($v, $array2) <=> $k];
    }

    print_r($result);

?>