note 51198 added to function.preg-replace
| From: | doron88 at gmail dot com | Date: | Wed, 23 Mar 2005 12:01:00 +0000 |
| Subject: | note 51198 added to function.preg-replace | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-86837@lists.php.net to get a copy of this message | ||
Hello all php experts :),
I have a little question:
I have a string, want to highlight all php codes from this string, how shall I do it?
that's my code:
<?php
function phpcode($string)
//finds and highlight php codes from the string
{
return preg_replace('!\[PHP\]\s*(.*?)\s*\[\/PHP\]!i',
'<br />PHP Code:<p dir="ltr">'.
highlight_string('$1',TRUE).
'</p>',
$string);
?>
----
Manual Page -- http://www.php.net/manual/en/function.preg-replace.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+51198
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+51198&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+51198&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+51198&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+51198&report=yes&reason=useless
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+51198&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+51198&report=yes
Search -- http://master.php.net/manage/user-notes.php