PHP defines two SPL exceptions for invalid keys:
OutOfRangeException: Exception thrown when an illegal index was requested. This represents errors that s
string but end up with an integer or vice versa. Then you should throw an UnexpectedValueException exception.warning (trigger_error) and proceed on. This is not expected to stop programming flow.OutOfBoundsException.OutOfRangeException.In layman's terms. An OutOfBoundsException is something normal. It's not that serious. It's something that happens often and should be taken care of. it can be used by iterators to keep reading data till there is no more to read. It is a logical error. Made by someone using the code not by someone writing the code.
An OutOfRangeException is something serious. Someone should look at the source code. Someone should find out what happened. This is important. Theoretically this was never supposed to happen. Call 911. It is a compile time error. Made by the dummy programmer.
Out of range exceptions are written by programmers to guard against mistakes by other programmers. Or maybe yourself in the future. If you feel like something like that could never happen then use Out Of Range. Use Out of Bounds for something likely to happen.