1--TEST-- 2Test strrpos() function : usage variations - repetitive chars for 'haystack' argument 3--FILE-- 4<?php 5/* Prototype : int strrpos ( string $haystack, string $needle [, int $offset] ); 6 * Description: Find position of last occurrence of 'needle' in 'haystack'. 7 * Source code: ext/standard/string.c 8*/ 9 10/* Test strrpos() function with strings containing multiple occurrences of 'needle' in the 'haystack' 11 * and with various needles & offsets 12*/ 13 14echo "*** Testing strrpos() function: strings repetitive chars ***\n"; 15$haystack = "ababababAbaBa"; 16$needle = "aba"; 17 18/* loop through to consider various offsets in getting the position of the needle in haystack string */ 19$count = 1; 20for($offset = -1; $offset <= strlen($haystack); $offset++ ) { 21 echo "-- Iteration $count --\n"; 22 var_dump( strrpos($haystack, $needle, $offset) ); 23 $count++; 24} 25echo "*** Done ***"; 26?> 27--EXPECTF-- 28*** Testing strrpos() function: strings repetitive chars *** 29-- Iteration 1 -- 30int(4) 31-- Iteration 2 -- 32int(4) 33-- Iteration 3 -- 34int(4) 35-- Iteration 4 -- 36int(4) 37-- Iteration 5 -- 38int(4) 39-- Iteration 6 -- 40int(4) 41-- Iteration 7 -- 42bool(false) 43-- Iteration 8 -- 44bool(false) 45-- Iteration 9 -- 46bool(false) 47-- Iteration 10 -- 48bool(false) 49-- Iteration 11 -- 50bool(false) 51-- Iteration 12 -- 52bool(false) 53-- Iteration 13 -- 54bool(false) 55-- Iteration 14 -- 56bool(false) 57-- Iteration 15 -- 58bool(false) 59*** Done ***