I want to add like when they write [ PHP]text[ /PHP], it should become <source lang="php">text</source>
How would I do that?
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 Code:<?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 own [php]block)Code:my new array: <source lang="php"><?php $my_array = array(); ?></source>
Last edited by Scoochi2; 11-09-2008 at 10:35 AM. Reason: [php] tag problem :(
If anyone can see it, my post was meant for anyone who reads it. Don't take it personally or think I'm being condescending... :nuts:
In that case, here's a few results from a quick Google search:
Understanding FCKe plugings
A possible similar plugin
If anyone can see it, my post was meant for anyone who reads it. Don't take it personally or think I'm being condescending... :nuts:
What scoochi2 posted should've worked, basically what you want is to use a string parser and string replace functions. so it should have worked.
Don't get me wrong as I believe if and when I help someone I also help myself whereby whatever someone learns I also learn.
But I will also accept credits or reps if you really want to part with it.
Indeed it does. The first thing I did was copy my entire code as is into a blank page.php
Next, I got rid of that space in the closing tag that I mentioned. Then I turned on PHP and ran it in my browser.
The following is what I saw:
That's exactly what I expected to see. Doesn't mean it's right though ;)my new array:
Next, I viewed the source of the page (because I know that the HTML <source> shouldn't give me any visible results, but as it is HTML, it will appear in the page source. The following is the source of my page:
So yes, it does workmy new array: <source lang="php"><?php $my_array = array(); ?></source>
Vigge, can you confirm the results? IE, did you view the page in your browser and think it's not showing the string? Can you check the source and see if it's in there at all?
Last edited by Scoochi2; 11-11-2008 at 06:30 PM. Reason: w00h00, this post made me a 'Sophmore' :D
If anyone can see it, my post was meant for anyone who reads it. Don't take it personally or think I'm being condescending... :nuts: