- var_dump: documentation ( source)
- preg_match: documentation ( source)
<?php
$string = 'hello world, world!';
# 0123456
var_dump(preg_match('/\Gworld/', $string, $matches, PREG_OFFSET_CAPTURE, 6), $matches[0]);
var_dump(preg_match('/\Gworld/', $string, $matches, PREG_OFFSET_CAPTURE, 3), $matches[0]);