I have a sample code:
$link = '<a href="http://test.com/t123#readmore" class="">Read more</a>';
And my code php add onlick event
$link = preg_replace( '#<a(.+?)href="(.+?)"(.+?)(</a>)#s', '<a href="$2" onclick="test();"></a>', $link);
But error can't add onclick on tag a, how to fix it ?
<a href="http://test.com/t123#readmore" onclick="test();" class="">Read more</a>