Re: Everything between something becomes an array element
| From: | Andrey Hristov | Date: | Mon, 05 Nov 2001 20:41:16 +0000 |
| Subject: | Re: Everything between something becomes an array element | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-73480@lists.php.net to get a copy of this message | ||
Keep in mind that the first closing </tr> is where the search will stop so
<tr><td><table><tr><td>foo</td><td>bar</td></tr></table></tr>
will return :
<tr><td><table><tr><td>foo</td><td>bar</td></tr>
On Monday 05 November 2001 03:37 pm, you wrote:
>
> $how=preg_match_all('|\<tr>.(*?)</tr\>|',$the_big_string,$matches,PREG_SET_
>ORDER); for ($counter=0;$counter<$how;$counter++){
> $big_array[]=$matches[$counter][1]; //0 is the whole matched string, 1 is
> // the first substring and so on
> }
>
> var_dump($big_array);
>
> Regards,
>
> Andrey Hristov
> Web Developer
> Icygen Corporation
> BUILDING SOLUTIONS
> http://www.icygen.com
>
> On Monday 05 November 2001 08:32 am, you wrote:
> > Hi All,
> >
> > I am playing with Regex this morning and could not find a solution. I
> > have a string (fread from a page) where several times <tr>'s and
> > </tr>'s
> > appear.
> >
> > What I am trying to accomplish is to put everything between <tr> and
> > </tr> in a 'place' where I can search for keywords later.
> >
> > I thought about making the middle content an array element but I don't
> > understand much of Regex.
> >
> > Anyone can help me?
> >
> > Thanks a lot.