In my preg_replace_callback I can allow some elements to be showing in preview using the preg_replace_callback
How ever when the user has typed in a link lets say <a href="http://www.example.com">Example</a>
The preview will only put out <a href="http://www.example.com">Example
Is there any way I can integrate this
Into the code below
How ever when the user has typed in a link lets say <a href="http://www.example.com">Example</a>
The preview will only put out <a href="http://www.example.com">Example
Is there any way I can integrate this
PHP Code:
preg_replace("~[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]~","<a href=\"\\0\">\\0</a>", $string)
Into the code below
PHP Code:
public function preview() {
$data = array('success' => false, 'question' => '');
if ($_POST) {
$string = $this->input->post('question');
$match = array(
'<' => '<',
'>' => '>',
);
$new_data = preg_replace_callback("#</?(pre|code|h1|h2|h3|h4|h5|h6|b|strong|i|u|hr)>|[<>]#", function ($match) {
return $match[0] == '<' ? '<' : ($match[0] == '>' ? '>' : $match[0]);
}, $string);
$data['question'] = parse_smileys($new_data, base_url('assets/img/smiley'));
$data['success'] = true;
}
$this->output
->set_content_type('application/json')
->set_output(json_encode($data));
}