I
I
IceJOKER2014-05-22 19:37:38
PHP
IceJOKER, 2014-05-22 19:37:38

Php array - how to implement bulk replacement?

There is an array

$arr = array(
'Первый', 'Второй', 'Третий', 'Четвертый', 'Пятый', 'Шестой', 'Седьмой', 'Абракадабра', 'Чупакабра'
);

Through $_POST comes an array with select multiple, depending on the user's choice, there are different values
$arr = array(
1,2,5
);
//или
$arr = array(
0,5,6
);

It is necessary to massively replace the values ​​0,1,2,3... with the first, second, etc., how to implement this without gcode?
Example
$_POST['data'] = array(0, 7, 8);
I want to get an array = array('First', 'Abracadabra', 'Chupacabra' );

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
Lubaev, 2014-05-22
@IceJOKER

$arr = array(
'Первый', 'Второй', 'Третий', 'Четвертый', 'Пятый', 'Шестой', 'Седьмой', 'Абракадабра', 'Чупакабра'
);

 $result = array_intersect_key($arr, array_flip($_POST));

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question