On 3/10/06, Weber Sites LTD <berber@xxxxxxxxxxxxxxx> wrote: > Hi > > I'm trying to go with your idea but I'm having difficulties with > preg_match_all. > I want the text between <?php and ?>. The use of preg_match_all bellow only > Returns text that is in a single line. If the <php is on one line and the ?> > is > A few lines bellow, it does not match. > > preg_match_all('/<\?php(.*?)\?>/i',$text,$CodeArray,PREG_PATTERN_ORDER); Try /is it will treat the string as one huge line. > -----Original Message----- > From: Chris [mailto:dmagick@xxxxxxxxx] > Sent: Tuesday, March 07, 2006 3:08 AM > To: Weber Sites LTD > Cc: php-general@xxxxxxxxxxxxx > Subject: Re: highlight_string() > > Weber Sites LTD wrote: > > I was afraid of that... > > I need to do HTML manipulations on the text that is outside the <??>. > > After I run highlight_string the original text is messed up. > > If I run the manipulations before then they will look like HTML And > > not act as HTML... > > > > Any ideas? > > You could get the php from your page, highlight it and replace it back in: > > preg_replace('%<?(.*)?>%s', 'highlight_string(${1})', $content); > > don't know if that will work straight out for you but that should give you > an idea on how to proceed. > > > Or you could temporarily remove them, do whatever then replace it back in: > > $placeholders = array(); > while(preg_match('%<?(.*)?>%s', $content, $matches)) { > $size = sizeof($placeholders); > $placeholders[$size] = $matches[1]; > $content = str_replace($matches[0], '%%PLACEHOLDER['.$size.']%%', > $content); > } > > ... other processing here. > > foreach($placeholders as $i => $text) { > $content = str_replace('%%PLACEHOLDER['.$i.']%%', > highlight_string($text), $content); > } > > > > -----Original Message----- > > From: chris smith [mailto:dmagick@xxxxxxxxx] > > Sent: Monday, March 06, 2006 11:59 AM > > To: Weber Sites LTD > > Cc: php-general@xxxxxxxxxxxxx > > Subject: Re: highlight_string() > > > > On 3/6/06, Weber Sites LTD <berber@xxxxxxxxxxxxxxx> wrote: > > > >>The only way I could work around this was to put empty <??> at the > >>Beginning of the text and now highlight_string() highlights only what > >>Is inside <? ?> > >> > >>You can see an example of the problematic text in the example Area of > >>this page : http://www.weberdev.com/get_example-4345.html > >> > >>Notice the empty <? ?> at the beginning of the example. > >>Without them, all of the example, including the text and HTML Part > >>will be painted by highlight_string(). > >> > >>Is this a bug? > > > > > > No. It will highlight html as well. > > > > You can give the illusion of it not highlighting the html by using: > > > > ini_set('highlight.html', '#000000'); -- Postgresql & php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php