check.php
bb.phpCode:<?php
if(isset($_POST['textarea1'])) {
$value = $_POST['textarea1'];
include "bb.php";
echo bb($value);
}
?>
<!DOCTYPE html>
<html>
<head>
</head>
<body>
</body>
</html>
Code:<?php
function bb($elem) {
while(substr_count($elem, '[red]') > 0 and substr_count($elem, '[/red]') > 0) {
$elem = preg_replace('[red]', '<span style="color:red">', $elem, 1);
$elem = preg_replace('[/red]', ',</span>', $elem, 1);
}
return $elem;
}
?>
$_POST['textarea1']is[red]hello[/red]
it outputs
[]hello[,]
when I would like it to output
hello
any help?

