September 10, 2013

Extract string from a tag using php

User1432345’s Question:

How to extract the link domain name using php.

Eg,

Search engine <a href="http://www.google.com">Google Search</a> and <a href="www.yahoo.co.in">Yahoo Search</a>

I need from this –

Search engine google and yahoo

You can remove all the HTML tags using strip_tags() (as stated in comments)

$text = 'Search engine <a href="http://www.google.com">Google</a> and <a href="www.yahoo.co.in">Yahoo</a>';
echo strip_tags($text); //This will give only the text

Author: Nabin Nepal (Starx)

Hello, I am Nabin Nepal and you can call me Starx. This is my blog where write about my life and my involvements. I am a Software Developer, A Cyclist and a Realist. I hope you will find my blog interesting. Follow me on Google+

...

Please fill the form - I will response as fast as I can!