Why is preg_match_all returning two matches?

It returns 2 elements because:

Element 0 captures the whole matched string

Elements 1..N capture dedicated matches.

PS: another way of expressing the same could be

(?<=")[^"]+(?=")

which would capture exactly the same but in that case you don't need additional capturing group.

Demo: http://regex101.com/r/lF3kP7/1


Hi if your are using print_r instead of vardump you will see the differences in a better way.

Array
(
    [0] => Array
        (
            [0] => "Test match this"
        )

    [1] => Array
        (
            [0] => Test match this
        )

)

The first contains whole string and the second is your match.