i would like to reproduce/convert this js script to a php script, is there anyone can help me? i think i need preg_replace() in php and i'm really not good with it :/
this is my js simple script:
wysiwyg_val = $('.wysiwyg textarea').val()
.replace(/
/g, "<br>")
.replace(/<br>/g,'[br]')
.replace(/\</g,'<')
.replace(/\>/g,'>')
.replace(/\{code\}/g, '<pre><code>')
.replace(/\{\/code\}/g, '</code></pre>')
.replace(/\{strong\}/g, '<strong>')
.replace(/\{\/strong\}/g, '</strong>')
.replace(/\{italic\}/g, '<i>')
.replace(/\{\/italic\}/g, '</i>')
.replace(/\{title\}/g, '<h2>')
.replace(/\{\/title\}/g, '</h2>')
.replace(/\{subtitle\}/g, '<h3>')
.replace(/\{\/subtitle\}/g, '</h3>')
.replace(/\[br\]/g,'<br>');
the wysiwyg_val
, after is escaped, is passed via Ajax to a php page which can take it as $_POST['text']