Hi All,
I'm a PHP newbie more experienced in Perl than PHP. I want to assign the results of multiple hits from a Regex to an array and then iterate through that array and apply a function to each hit.
In Perl I would do it like:
@hits = $article =~ /\b([A-Z]{2} [0-9]{4})\b/gi;
foreach (@hits) {
my ($cleanuup_hit) = &clean_up ($_);
}
However, I can't seem to find anything similar in PHP. Does anyone know how I might be able to achieve this in PHP?
Apologies if this question has been asked before, but I have searched the posts and can't find anything.
Thanks in anticipation
Chris K
Assigning hits from Reg Ex to an Array: Perl to PHP
Moderator: General Moderators
-
Mark Baker
- Forum Regular
- Posts: 710
- Joined: Thu Oct 30, 2008 6:24 pm
Re: Assigning hits from Reg Ex to an Array: Perl to PHP
take a look at the preg_match_all() function