regex - finding multiple occurances of a pattern and extracting a string

19 Views Asked by At

i have a code

<?php
$string='afdsfd data-win="3453453ASSS" some text data-win="3434534ASDDD" some more text data-win="1233RTYYY"';
preg_match_all('/data-win="([^"]+)"/', $string, $matches);
print_r($matches);
?>

this is the output i get

Array (
    [0] => Array
        (
            [0] => data-win="3453453ASSS"
            [1] => data-win="3434534ASDDD"
            [2] => data-win="1233RTYYY"
        )

    [1] => Array
        (
            [0] => 3453453ASSS
            [1] => 3434534ASDDD
            [2] => 1233RTYYY
        )

)

what am, i doing wrong ? All i wanted was Array[1] and not Array[0]

0

There are 0 best solutions below