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

What is php regular expression?

0 Answers  


what mode to use when creating dirs with mkdir?

1 Answers  


How can we destroy the session, how can we unset the variable of a session?

3 Answers  


Explain the difference between static and dynamic websites?

0 Answers  


What is slim framework?

0 Answers  


What is php oop?

0 Answers  


What is difference between python and php?

0 Answers  


How to restrict the number of users login ? For ex:- if the allowed login is 10, for 11th user, the application should restrict them from login.

1 Answers  


What is the most common http method?

0 Answers  


Which array function checks if the particular key exists in the array?

0 Answers  


Does cors prevent csrf?

0 Answers  


What is the purpose of the following files having extensions: frm, myd, and myi? What these files contain?

0 Answers  


Categories