The indexOf() method returns the first index at which a given element can be found in the array, or -1 if it is not present.

@param mixed $searchElement
@param int $fromIndex
@return int|string
18349
public function indexOf($searchElement, $fromIndex = 0)
    {
        $result = array_search($searchElement, $this->getArrayCopy(), true);

        return $result === false ? -1 : $result + $fromIndex;

        // if ($fromIndex < 0) {
        //     $fromIndex = $this->length() + $fromIndex;
        // }
        // $result = array_search($searchElement, $this->slice($fromIndex)->getArrayCopy(), true);

        // return $result === false ? -1 : $result + $fromIndex;
    }
41338
public function indexOf( AbstractElement $element ) {
		$search_result = array_search($element, $this->childElements, true);

		return $search_result === false ? null : $search_result;
	}
1121932
function locator(value, fromIndex) {
    var result
    var prev

    regex.lastIndex = fromIndex

    result = regex.exec(value)

    if (result) {
      result = regex.lastIndex - result[0].length
      prev = value.charCodeAt(result - 1)

      if (usernameCharacter(prev) || prev === CC_HASH || prev === CC_AT) {
        /* Find the next possible value. */
        return locator(value, regex.lastIndex)
      }

      return result
    }

    return -1
  }
1102508
private int findIndexOfFrom(String query) {
    if (query.startsWith("from")) return 0;
    int fromIdx = query.indexOf(" from ");
    if (-1 == fromIdx) return -1;
    final int first = query.substring(0, fromIdx).indexOf("(");
    if (first > 0) {
      int leftCnt = 1;
      int i = first + 1;
      while (leftCnt != 0 && i < query.length()) {
        if (query.charAt(i) == '(') leftCnt++;
        else if (query.charAt(i) == ')') leftCnt--;
        i++;
      }
      if (leftCnt > 0) return -1;
      else {
        fromIdx = query.indexOf(" from ", i);
        return (fromIdx == -1) ? -1 : fromIdx + 1;
      }
    } else {
      return fromIdx + 1;
    }
  }
262775
protected function findTagIndex(array $tokens, int $from, int $to, string $tagType): ?int
    {
        for ($i = $from + 1; $i < $to; $i++) {
            if ($tokens[$i]['code'] === $tagType) {
                return $i;
            }
        }

        return null;
    }
685527
public function at($index)
    {
        if (isset($this->_children[$index])) {
            return $this->_children[$index];
        }
        throw new OutOfBoundsException("Index $index does not exist");
    }
232638
public function indexOf($str, $from = 0, $cs = CaseSensitivity::CASE_INSENSITIVE)
    {
        $toSearch = (string)$str;

        switch ($cs) {
            case CaseSensitivity::CASE_INSENSITIVE:
                $pos = stripos($this->text, $toSearch, $from);
                break;
            case CaseSensitivity::CASE_SENSITIVE:
                $pos = strpos($this->text, $toSearch, $from);
                break;
            default:
                throw new MWrongTypeException("\$cs", "CaseSensitivity", $cs);
                break;
        }

        if ($pos === false) {
            return -1;
        }

        return $pos;
    }
966437
public static int indexAny(String target, Integer fromIndex, List<String> indexWith) {
		if (isNull(target)) {
			return INDEX_NONE_EXISTS;
		}
		
		return matcher(target).indexs(fromIndex, checkNotNull(indexWith).toArray(new String[indexWith.size()]));
	}
277527
public function indexOf($searchValue, $fromIndex = 0)
    {
        if (empty($searchValue) === true) {
            return $fromIndex;
        }

        $result = strpos($this->subject, $searchValue, $fromIndex);

        return $result === false ? -1 : $result;
    }
209968
private static int lastIndexOf(Object o, Object[] elements, int index) {
        if (o == null) {
            for (int i = index; i >= 0; i--)
                if (elements[i] == null)
                    return i;
        } else {
            for (int i = index; i >= 0; i--)
                if (o.equals(elements[i]))
                    return i;
        }
        return -1;
    }
1296320
public function getNextSiblingOf( AbstractElement $element ) {
		$index = $this->indexOf($element);

		return $this->childAtIndex($index + 1);
	}
1247371
protected function _findTagIndex(array $tokens, $from, $to, $tagType) {
		for ($i = $from + 1; $i < $to; $i++) {
			if ($tokens[$i]['code'] === $tagType) {
				return $i;
			}
		}

		return null;
	}
490915
public function getPreviousSiblingOf( AbstractElement $element ) {
		$index = $this->indexOf($element);

		return $this->childAtIndex($index - 1);
	}
638603
public static int indexOf(final CharSequence cs, final char searchChar, int start) {
        if (cs instanceof String) {
            return ((String) cs).indexOf(searchChar, start);
        } else if (cs instanceof AsciiString) {
            return ((AsciiString) cs).indexOf(searchChar, start);
        }
        if (cs == null) {
            return INDEX_NOT_FOUND;
        }
        final int sz = cs.length();
        for (int i = start < 0 ? 0 : start; i < sz; i++) {
            if (cs.charAt(i) == searchChar) {
                return i;
            }
        }
        return INDEX_NOT_FOUND;
    }
666336
function indexOf(arr, searchval) {

        var min = 0;
        var max = arr.length - 1;
        var cur;

        while (min <= max) {

            cur = Math.floor((min + max) / 2);

            var curval = arr[cur];

            if (curval < searchval) {

                min = cur + 1;

            } else if (curval > searchval) {

                max = cur - 1;

            } else {

                return {found: true, index: cur};

            }

        }

        return {found: false, index: min};
    }
1367673
public int indexs(final Integer fromIndex, String... indexWith) {
		int index = INDEX_NONE_EXISTS;
		final String target = ignoreCase ? delegate.get().toLowerCase() : delegate.get();
		
		for (String input : indexWith) {
			String target2 = ignoreCase ? input.toLowerCase() : input;
			if ((index = target.indexOf(target2, fromIndex)) >= 0) {
				return index;
			}
		}
		
		return index;
	}
849455
public function index($selector=null)
    {
        if ($selector === null) {
            if ($node = $this->getFirstElmNode()) {
                $position = 0;
                while ($node && ($node = $node->previousSibling)) {
                    if ($node instanceof \DOMElement) {
                        $position++;
                    } else {
                        break;
                    }
                }
                return $position;
            }
        } else {
            foreach ($this as $key => $node) {
                if ($node->is($selector)) {
                    return $key;
                }
            }
        }

        return -1;
    }