Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $text = '<p>This is a</p>
- <h1>Test</h1>
- <p>to see if this works </p>';
- $regex = '/<h([0-6]{1})>(.+)</h[0-6]{1}>/';
- echo preg_replace($regex, '<h$1><a name="$2">$2</a></h$1>', $text);
- <p>This is a</p>
- <h1><a name="Test">Test</a></h1>
- <p>to see if this works </p>
- Header 1 {#header1}
- ========
- ## Header 2 ## {#header2}
- [Link back to header 1](#header1)
Add Comment
Please, Sign In to add comment