- Messages
- 5,508
- Reaction score
- 35
- Points
- 48
I want to add like when they write [ PHP]text[ /PHP], it should become <source lang="php">text</source>
How would I do that?
How would I do that?
Last edited:
<?php
$string = 'my new array: [php]<?php $my_array = array(); ?>[/ php]';
$string = preg_replace("/\[php\](.+?)\[\/php\]/","<source lang=\"php\">$1</source>",$string);
echo $string;
?>
my new array: <source lang="php"><?php $my_array = array(); ?></source>
block)
I personally have never used and don't know FCKeditor, but if you have the string as a variable in PHP (for example, by submitting a form with the POST method), then the following will do just that:
will output:PHP:<?php $string = 'my new array: [php]<?php $my_array = array(); ?>[/ php]'; $string = preg_replace("/\[php\](.+?)\[\/php\]/","<source lang=\"php\">$1</source>",$string); echo $string; ?>
(space in example [/php] to prevent ending my ownCode:my new array: <source lang="php"><?php $my_array = array(); ?></source>
PHP:block)[/quote] nope does not work
Indeed it does. The first thing I did was copy my entire code as is into a blank page.phpWhat scoochi2 posted should've worked, basically what you want is to use a string parser and string replace functions. so it should have worked.
That's exactly what I expected to see. Doesn't mean it's right thoughmy new array:
my new array: <source lang="php"><?php $my_array = array(); ?></source>