Vorrei che i link presenti in una stringa di testo tipo:
[(n)]
si trasformino in:
<div id "_ftn(n)" >[(n)]</div>
La stringa contenente:
Codice PHP:
testo testo testo [url="#_ftnref1"][1][/url] testo testo testo
testo [url="#_ftnref2"][2][/url] testo testo testo testo
testo [url="#_ftnref3"][3][/url] testo testo testo testo
testo <a href=\"www.cicca.it\">questo invece rimane invariato</a>"
si dovrebbe trasformare in:
Codice PHP:
testo testo testo <div id "_ftn1" >[url="#_ftnref1"][1][/url]</div> testo testo testo
testo <div id "_ftn2" >[url="#_ftnref2"][2][/url]</div> testo testo testo testo
testo <div id "_ftn3" >[url="#_ftnref3"][3][/url]</div> testo testo testo testo
testo <a href=\"www.cicca.it\">questo invece rimane invariato</a>"
Questo sembra funzionare eccetto che <div id="_ftn">, che ovviamente rimane così per tutti.
Come faccio a farli diventare "_ftn1", "_ftn2", "_ftn3"? (il numero deve ovviamente corrispondere al "#_ftnref(n) corrispondente")
Codice PHP:
preg_replace('~(<a href="([^"]+)">([^<]+)<\/a>)~','<div id="_ftn">$1</div>', $contenuto);
Grazie e