是否有用于从索引数组生成关联数组的php函数

Array
(
    [0] => '1 Fail'
    [1] => '2 Fail'
    [2] => '3 Pass'
    [3] => '4 Pass'
    [4] => '5 Pass'
)

Array
(
    ['1 Fail'] => '1 Fail'
    ['2 Fail'] => '2 Fail'
    ['3 Pass'] => '3 Pass'
    ['4 Pass'] => '4 Pass'
    ['5 Pass'] => '5 Pass'
)

Is there a php function to convert from array 1 to array 2

PS: I know this so i am looking for a built in function

foreach($result as $value)
{
    $assoc[$value] = $value;
}

Assuming all your array values are unique:

$assoc = array_combine(array_values($arr), array_values($arr));

You could:

array_walk($array, function ($value, &$key) {
  $key = $value;
});

...but a more pertinent point is: why do you need to do this?

It seems like this is a very odd requirement, and whatever you need to do would be better done some other way...

You can use array_combine

$arr    = array(
'1 fail',
'2 fail',
'3 fail',
'4 fail',
);
print_r(array_combine($arr, $arr));



Array
(
    [1 fail] => 1 fail
    [2 fail] => 2 fail
    [3 fail] => 3 fail
    [4 fail] => 4 fail
)