Example #1
0
 public function testOffsetsException()
 {
     $this->setExpectedException('\\r8\\Exception\\Argument');
     \r8\str\offsets('', 'Stringy string with multiple occurances of the word string');
 }
Example #2
0
/**
 * Get the position of the nth needle in the haystack
 *
 * @param String $needle The string being searched for
 * @param String $haystack The string that you trying to find the needle in
 * @param Boolean $ignoreCase Whether the search should be case sensitive
 * @param Integer $wrapFlag How to handle offset wrapping when the offset, per {@link calcWrapFlag()}.
 * @return Integer Returns the offsets, from 0, of the needle in the haystack
 */
function npos($needle, $haystack, $offset, $ignoreCase = TRUE, $wrapFlag = \r8\ary\OFFSET_RESTRICT)
{
    $found = \r8\str\offsets($needle, $haystack, $ignoreCase);
    if (count($found) <= 0) {
        return FALSE;
    } else {
        return \r8\ary\offset($found, $offset, $wrapFlag);
    }
}