Re: Everything between something becomes an array element
| From: | Andrey Hristov | Date: | Tue, 06 Nov 2001 15:17:43 +0000 |
| Subject: | Re: Everything between something becomes an array element | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-73558@lists.php.net to get a copy of this message | ||
But .... watch this...
<body>
<table><tr><td><table><tr><td>foo</td><td>bar</td></tr></table></tr></table>
<table><tr><td>foo bar</td></tr></table>
</body>
I think that the return result will be
<tr><td><table><tr><td>foo</td><td>bar</td></tr></table></tr></table>
<table><tr><td>foo bar</td></tr>
Why? Beacuse you set PCRE to be greedy. I think that there is no easy way to
solve the problem with nested <tr> tags.
Regards,
Andrey Hristov
Web Developer
Icygen Corporation
BUILDING SOLUTIONS
http://www.icygen.com
On Tuesday 06 November 2001 02:57 am, you wrote:
> Here is right implememtation of all i see
>
> <?
> $co=0;
>
> $str="<tr><td><table><tr><td>foo</td><td>bar</td></tr></table></tr>";
> echo "<pre>";
> GetTagElements($str);
> echo "</pre>";
>
> function GetTagElements($str)
> {
> global $co;
> if ($co++){echo "tag[".($co-1)."]=
> ".htmlentities($str)."<br>";}
>
>
>
> $how=preg_match_all('~\<tr\>(.*)<\/tr\>~',$str,$var_match,PREG_SET_ORDER);
> if ($how)
> for ($i=1;$i<count($vr=$var_match[0]);$i++)
> {
> GetTagElements($vr[$i]);
> }
> else return 0;
> }
>
> ?>
>
> > -----Original Message-----
> > From: Andrey Hristov [mailto:andy@icygen.com]
> > Sent: Monday, November 05, 2001 11:13 PM
> > To: php-general@lists.php.net
> > Subject: Re: [PHP] Everything between something becomes an array element
> >
> >
> > Sorry
> >
> > $how=preg_match_all('|\<tr>(.*?)</tr\>|',$the_big_string,$matches,
> > PREG_SET_O
> > RDER);
> >
> > is the correct I think
> >
> > Excuses
> >
> > On Monday 05 November 2001 08:57 am, you wrote:
> > > It gives me an error....:
> > >
> > > Warning: Compilation failed: nothing to repeat at offset 7 in
> > > c:\www\innocenti\teste.php on line 17
> > >
> > > I think that 'offset' is like a letter from the regex, but I
> >
> > could not fix
> >
> > > it...
--