Demo For: Using PHP To Find Value In Array

Example 1: Declare an array with unique values. =========================================/

Following are the original array contents:
Array
(
    [0] => apple
    [1] => mango
    [2] => grapes
    [3] => pineapple
)
The key of the grapes value is: 2

Example 2: Declare an array with duplicate values. We will find index/key of repeated values. ============/

Following are the array contents with duplicated values:
Array
(
    [0] => apple
    [1] => mango
    [2] => grapes
    [3] => pineapple
    [4] => grapes
)
Print all indicies of the values found in array:
Array
(
    [0] => 2
    [1] => 4
)