HardCoreMore Posted January 28, 2011 Share Posted January 28, 2011 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 More sharing options...
trq Posted January 28, 2011 Share Posted January 28, 2011 preg_match_all. Link to comment https://forums.phpfreaks.com/topic/225945-finding-all-matches/#findComment-1166466 Share on other sites More sharing options...
HardCoreMore Posted January 28, 2011 Author Share Posted January 28, 2011 hahahahah thanks preg_match_all() hahahha thanks i would never guessed it thank you Link to comment https://forums.phpfreaks.com/topic/225945-finding-all-matches/#findComment-1166468 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.