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 from the right, but the third parameter (11) limits the search to positions 0-11. In abcdefghiklmdef (indices 0-15), searching backwards from position 11 finds def at position 3. This is the first def from the left that's within the search boundary. Option B is correct. The last def starts at position 13, outside the search range.