Welcome Guest, Not a member yet? Register   Sign In
problem with [coder] tags in article
#1

[eluser]double_d[/eluser]
Hi all,

Thing I want to do is to use
Code:
highlight_code
on text between [coder][/coder] tags.

got kind of a problem with preg_match (that was first thing I found to use...)

I didn't find any CI function that would do what I want (I was looking in text helper).


here is the code...

Code:
$str = 'bla bla bla [coder]#!/bin/bash
cat banner.txt
OPTIONS="SERVER1 SERVER2 SERVER3 QUIT"
select opt in $OPTIONS; do
if [ "$opt" = "QUIT" ]; then
echo Bye...
exit
elif [ "$opt" = "SERVER1" ]; then
ssh user@server1_IP
elif [ "$opt" = "SERVER2" ]; then
ssh user@server2_IP
elif [ "$opt" = "SERVER3" ]; then
ssh user@server3_IP
else
clear
echo "error, no such option"
fi
done[/coder] bla bla bla';

$ref = preg_match("/[coder](.*)[\/coder]/", $str, $matches);

$string = highlight_code($matches[1]);

echo $string;

but output on page is only oder]#!/bin

Did I overlook some CI function or smthn, and if there isn't any what is wrong with my code...

tnx in advance


Messages In This Thread
problem with [coder] tags in article - by El Forum - 12-01-2008, 08:45 AM
problem with [coder] tags in article - by El Forum - 12-01-2008, 08:58 AM
problem with [coder] tags in article - by El Forum - 12-01-2008, 09:03 AM
problem with [coder] tags in article - by El Forum - 12-01-2008, 09:11 AM
problem with [coder] tags in article - by El Forum - 12-01-2008, 09:42 AM
problem with [coder] tags in article - by El Forum - 12-01-2008, 10:51 AM



Theme © iAndrew 2016 - Forum software by © MyBB