[Solved] Using preg_replace_callback with a href |
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 PHP Code: preg_replace("~[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]~","<a href=\"\\0\">\\0</a>", $string) Into the code below PHP Code: public function preview() {
There's only one rule - please don't tell anyone to go and read the manual. Sometimes the manual just SUCKS!
If it's dropping the end of the link do a check and if it's a link concat the end on to it.
What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
PHP Code: $string .= 'What you need here'; Do that after you check the string and do your replacing. What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
Update
I have added it in like this now but now prints it out twice PHP Code: $string = $this->input->post('question');
There's only one rule - please don't tell anyone to go and read the manual. Sometimes the manual just SUCKS!
Try this one:
PHP Code: $new_data = preg_replace_callback("#</?(pre|code|h1|h2|h3|h4|h5|h6|b|strong|i|u|hr)>|[<>]#", function ($match) { What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
I did a couple changes on my script and got it working
There's only one rule - please don't tell anyone to go and read the manual. Sometimes the manual just SUCKS!
|
Welcome Guest, Not a member yet? Register Sign In |