How can we extract string 'techinterviews.com' from a string
'http://www.techinterviews.com' using regular expression in PHP?

Answers were Sorted based on User's Feedback



How can we extract string 'techinterviews.com' from a string 'http://www.techintervi..

Answer / rajeev raj karn

$url="http://www.techinterviews.com";
$url_part=split("w{1,3}[\.]",$url);
echo $url_part[1];

Is This Answer Correct ?    3 Yes 0 No

How can we extract string 'techinterviews.com' from a string 'http://www.techintervi..

Answer / ram

$url = "http://www.techinterviews.com";
$splittedstring = explode ("www.",$url );
$str = $splittedstring[1];
echo $str ;

Is This Answer Correct ?    0 Yes 0 No

How can we extract string 'techinterviews.com' from a string 'http://www.techintervi..

Answer / sunil kumar

echo
strstr("http://www.techinterviews.com","techinterviews.com");

Is This Answer Correct ?    8 Yes 9 No

How can we extract string 'techinterviews.com' from a string 'http://www.techintervi..

Answer / brett

echo str_ireplace('http://www.','',$url);

Is This Answer Correct ?    3 Yes 8 No

Post New Answer

More PHP Interview Questions

Is php used anymore?

0 Answers  


What are php variables?

0 Answers  


Do you know what is the function mysql_pconnect() usefull for?

0 Answers  


What is sql injection in php?

0 Answers  


What does the unset() function mean?

0 Answers  


What is use of count() function in php?

0 Answers  


Tell us what is the difference between session_unregister() and session_unset()?

0 Answers  


How can we set and destroy the cookie in php?

0 Answers  


What is isset in php?

0 Answers  


What is .htaccessfile and use of this file

5 Answers  


What is the correct and the most two common way to start and finish a php block of code?

0 Answers  


How to pass variables and data from php to javascript?

0 Answers  


Categories