Jump to content

Finding all matches?


HardCoreMore

Recommended Posts

Hi all,

 

 

Why i can't get all the a's and their indexes.

 

This is the script:

 


$s1 = "a a vvvaaa  sdfdsaaa   ffss  afdsaaaaa";


$t = preg_match( '/(a*)/i', $s1, $m, PREG_OFFSET_CAPTURE );


echo '<pre>';

print_r( $m );

echo '</pre>';

 

 

 

This is what i get:

 

Array
(
    [0] => Array
        (
            [0] => a
            [1] => 0
        )

    [1] => Array
        (
            [0] => a
            [1] => 0
        )

)

 

I am getting just the first a at index 0 twice

Link to comment
https://forums.phpfreaks.com/topic/225945-finding-all-matches/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.