Re: [PHP3] My eregi() code will not work.

From: Date: Fri, 02 Jun 2000 19:47:24 +0000
Subject: Re: [PHP3] My eregi() code will not work.
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-920@lists.php.net to get a copy of this message
Ted Knudson wrote: > > Will I be embarrassed because there is a simple answer? It seems that most > of my questions have been caused by typos. > > I can not got get this code to work. I hope someone can help. Thanks. > > None of the $matches[] will print anything. > I have tried "<br>","^<br>","^<br>+" > > <?php > $Note = "<br>This is line 1.<br>This is line 2.<br>This is line > 3.<br>"; > > eregi("<br>", $Note, $matches); > Print $Note."<br>"; > Print $matches[0]."0<br>"; > Print $matches[1]."1<br>"; > Print $matches[2]."2<br>"; > Print $matches[3]."3<br>"; > > ?> You'll need to have parentheses in the regex. Something like this: eregi ("(<br>)", $Note, $matches); Then the values in $matches should be: $matches[0] = "<br>This is line 1.<br>This is line 2.<br>This is line 3.<br>" $matches[1] = "<br>" // namely the first "<br>" in the string. I don't know, however, if any of the other "<br>" substrings will be matched and put into $matches... i.e.: $matches[2] = "<br>" // the second "<br>" $matches[3] = "<br>" // the last "<br>" Stephen.

« previous php.general (#920) next »