src/Bag.php
public function indexOf($item, $fromIndex = 0)
    {
        foreach ($this->iterateFromIndex($fromIndex) as $key => $value) {
            if ($value === $item) {
                return $key;
            }
        }

        return null;
    }
public function indexOf($item, $fromIndex = 0)
    {
        foreach ($this->iterateFromIndex($fromIndex) as $key => $value) {
            if ($value === $item) {
                return $key;
            }
        }

        return null;
    }
public function indexOf ( $ item , $ fromIndex = 0 ) { foreach ( $ this -> iterateFromIndex ( $ fromIndex ) as $ key => $ value ) { if ( $ value === $ item ) { return $ key ; } } return null ; }
Gets the first index/key of a given item.

This uses a strict check so types must much and objects must be the same instance to match.

@param mixed $item      The item to search for
@param int   $fromIndex The starting index to search from.
Can be negative to start from that far from the end of the array.
If index is out of bounds, it will be moved to first/last index.

@return int|string|null The index or key of the item or null if the item was not found
Gets the first index / key of a given item .