php - How can I get a piece of text scanned and have all hyperlinks "behind the text" replaced with HTML attribute tags? -


i have page consists of html, css, , php. administrator page 1 of websites posting information found other websites. basically, need code block(whether php or javascript don't care) automatically search through text, find links, , convert links tags link text within them. have been researching long time on how accomplish this, can't seem find applies situation.

to review trying in more basic way: have admin page has several inputs , textarea. want block of code check text within textarea , find links, , replace them link text tags. reason need work because consistently pasting text has links included in already.

as example, want text..

google

automatically replaced with..

<a href="google.com">google</a> 

i prefer solution consist of php only, if have to, not mind working javascript somewhat.

edit:

basically had paste script in tag within html:

<script src="//tinymce.cachefly.net/4.0/tinymce.min.js"></script> <script> tinymce.init({selector:'textarea'}); </script>

this automatically converts textarea tags "rich" editor functions same textara, works better! hope useful others!

textarea alone cannot this. need use javascript-based text-editor such tinymce or ckeditor unless want re-invent wheel.


Comments