Multiple choice technology programming languages

If \$string contains abcdefghijiklmdef , what will the following call return? rindex(\$string , "def", 11 );

  1. 14

  2. 3

  3. 4

  4. 15

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

rindex searches for the last occurrence of a substring, optionally limited to a position. In 'abcdefghijiklmdef', the last 'def' ending at or before position 11 is at position 3 (0-indexed). The function returns the starting position of 'def' found in the first half of the string, not the later occurrence.