Is it possible that I can get the data from the other array based on the value from another?
If I input value from array it will return a value from other array.
Example:
$arr1 = ['A','B','C'];
$arr2 = [1,2,3,];
Input: 2
Result: B
Do they need to be separate?
You could use array_combine() to assign a key to the value and then input is just $array[$input] - e.g.
$arr1 = ['A', 'B', 'C'];
$arr2 = [1, 2, 3];
$arr = array_combine($arr2, $arr1);
echo $arr[$_POST['input']]; # will display 2
array_combine().array_search() xD haha :parray_search() will return the first instance of the result (in this case, 2), while array_combine() will return the last. So the two approaches will give different results if there are duplicate values in $arr2, as seen here: 3v4l.org/BZg0eSince your arrays have not been given any specific keys, they are assigned numerically indexes from PHP, starting from zero.
You can then use array_search() to get the key of the $arr2 array, and use that to find the value in $arr1.
$key = array_search($input, $arr2);
$output = $arr1[$key];
If either array has defined indexes, you can use array_values() to just get the values and get the numeric indexes from PHP again.
This function combine 2 or more arrays
<?php
$array1 = array('A', 'B', 'C');
$array2 = array('1', '2', '3');
$result = array_merge($array1, $array2);
print_r($result);
?>