PHP: Regex match anchor text and url in a string


To match anchor text and url in a string: $sourcestring = 'this is a good test <strong><a href="http://wordpress.org">file (.docx)</a></strong>  and this is the new <a href="wp-content/uploads/amir.jpg">site image</a> '; preg_match_all('/<a[^>]+href=[\'|"]([^>]+)[^>]+>([^<]+)<\/a>/i',$sourcestring,$matches); var_dump($matches);

Strip HTML tags and it’s contents too


To strip tags we can use the php function strip_tags($str) but it will return the content of the tags too, How to strip html tags and remove it's contents too ? /** * Remove HTML tags, including invisible text such as style and * script code, and embedded objects. Add line breaks around * block-level … Continue reading Strip HTML tags and it’s contents too