RE: [PHP] highlight_string()
Hi I found an example for this on WeberDev and got it to work pretty good. However, when I started to check, I now have a different issue. Till now, I just highlighted all of the text. Now I take the php code Out, highlight only the php code and put it back in. The problem is that I'm looking for anything between And some of the code examples have .?> So what I really take out is How can I avoid this? thanks -Original Message- From: chris smith [mailto:[EMAIL PROTECTED] Sent: Friday, March 10, 2006 1:19 PM To: Weber Sites LTD Cc: php-general@lists.php.net Subject: Re: [PHP] highlight_string() On 3/10/06, Weber Sites LTD <[EMAIL PROTECTED]> wrote: > Hi > > I'm trying to go with your idea but I'm having difficulties with > preg_match_all. > I want the text between . The use of preg_match_all bellow > only Returns text that is in a single line. If the 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:[EMAIL PROTECTED] > Sent: Tuesday, March 07, 2006 3:08 AM > To: Weber Sites LTD > Cc: php-general@lists.php.net > Subject: Re: [PHP] 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:[EMAIL PROTECTED] > > Sent: Monday, March 06, 2006 11:59 AM > > To: Weber Sites LTD > > Cc: php-general@lists.php.net > > Subject: Re: [PHP] highlight_string() > > > > On 3/6/06, Weber Sites LTD <[EMAIL PROTECTED]> 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', '#00'); -- Postgresql & php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] highlight_string()
On 10/03/06, Weber Sites LTD <[EMAIL PROTECTED]> wrote: > Hi > > I'm trying to go with your idea but I'm having difficulties with > preg_match_all. > I want the text between . The use of preg_match_all bellow only > Returns text that is in a single line. If the > is > A few lines bellow, it does not match. > > preg_match_all('/<\?php(.*?)\?>/i',$text,$CodeArray,PREG_PATTERN_ORDER); > By default a '.' matches any character except for a newline. If you want it to match *everything* you have to use the 's' pattern modifier - just stick an 's' on the very end of your pattern, after the 'i'. /<\?php(.*?)\?>/is -robin
Re: [PHP] highlight_string()
On 3/10/06, Weber Sites LTD <[EMAIL PROTECTED]> wrote: > Hi > > I'm trying to go with your idea but I'm having difficulties with > preg_match_all. > I want the text between . The use of preg_match_all bellow only > Returns text that is in a single line. If 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:[EMAIL PROTECTED] > Sent: Tuesday, March 07, 2006 3:08 AM > To: Weber Sites LTD > Cc: php-general@lists.php.net > Subject: Re: [PHP] 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:[EMAIL PROTECTED] > > Sent: Monday, March 06, 2006 11:59 AM > > To: Weber Sites LTD > > Cc: php-general@lists.php.net > > Subject: Re: [PHP] highlight_string() > > > > On 3/6/06, Weber Sites LTD <[EMAIL PROTECTED]> 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', '#00'); -- Postgresql & php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] highlight_string()
Hi I'm trying to go with your idea but I'm having difficulties with preg_match_all. I want the text between . The use of preg_match_all bellow only Returns text that is in a single line. If the is A few lines bellow, it does not match. preg_match_all('/<\?php(.*?)\?>/i',$text,$CodeArray,PREG_PATTERN_ORDER); Thanks. -Original Message- From: Chris [mailto:[EMAIL PROTECTED] Sent: Tuesday, March 07, 2006 3:08 AM To: Weber Sites LTD Cc: php-general@lists.php.net Subject: Re: [PHP] 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:[EMAIL PROTECTED] > Sent: Monday, March 06, 2006 11:59 AM > To: Weber Sites LTD > Cc: php-general@lists.php.net > Subject: Re: [PHP] highlight_string() > > On 3/6/06, Weber Sites LTD <[EMAIL PROTECTED]> 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', '#00'); > > -- > Postgresql & php tutorials > http://www.designmagick.com/ > > > -- Postgresql & php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] 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:[EMAIL PROTECTED] Sent: Monday, March 06, 2006 11:59 AM To: Weber Sites LTD Cc: php-general@lists.php.net Subject: Re: [PHP] highlight_string() On 3/6/06, Weber Sites LTD <[EMAIL PROTECTED]> 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', '#00'); -- Postgresql & php tutorials http://www.designmagick.com/ -- Postgresql & php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] highlight_string()
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? -Original Message- From: chris smith [mailto:[EMAIL PROTECTED] Sent: Monday, March 06, 2006 11:59 AM To: Weber Sites LTD Cc: php-general@lists.php.net Subject: Re: [PHP] highlight_string() On 3/6/06, Weber Sites LTD <[EMAIL PROTECTED]> 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', '#00'); -- Postgresql & php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] highlight_string()
> 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? > > -Original Message- > From: Weber Sites LTD [mailto:[EMAIL PROTECTED] > Sent: Monday, March 06, 2006 11:29 AM > To: php-general@lists.php.net > Subject: [PHP] highlight_string() > > Hi > > From what I see, highlight_string() should only change text between ?>. > Any idea why it highlights all of the text I send to it (even text outside > ? > > Thanks > > berber > > -- > PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: > http://www.php.net/unsub.php > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > Hi guys! Maybe you could take a look at this code: http://aidanlister.com/repos/v/PHP_Highlight.php Best regards /Gustav Wiberg -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] highlight_string()
On 3/6/06, Weber Sites LTD <[EMAIL PROTECTED]> 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', '#00'); -- Postgresql & php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] highlight_string()
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? -Original Message- From: Weber Sites LTD [mailto:[EMAIL PROTECTED] Sent: Monday, March 06, 2006 11:29 AM To: php-general@lists.php.net Subject: [PHP] highlight_string() Hi >From what I see, highlight_string() should only change text between . Any idea why it highlights all of the text I send to it (even text outside ? Thanks berber -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php