2013-05-20 1 views
-1

가 좋아, http://hello.com/api/thispart.php어떻게이 URL의 특정 부분 출력 preg_match를받을 수 있나요? 나는 URL이있는 경우

는 어떻게는 preg_match() 함수는 단지 thispart

지금까지 내가

preg_match('@^(?:http://)?([^/]+)@', "http://hello.com/api/thispart.php", $matches) 
echo " <br>Domain name is: $matches[0] <br>"; 
echo " <br>Domain name is: $matches[1]; 

에서 찾고 선택 얻을 수있는 출력은

입니다
Domain name is: http://hello.com 

Domain name is: hello.com 

하지만 난 그냥 출력을 원하는 thispart

답변

0

당신이 basename, 도트에서 다음 explode를 사용할 수없는 이유는?

+0

이 거의 작동합니다. 나는이 작업을 수행 할 때 그것은 새로운 라인 문자 다음에 thispart을주고, 그래서 비교를 사용할 수 없습니다. – Freiermuth

+0

감사합니다. 매우 도움이되었습니다. 이것은 내가 필요로하는 것을 얻었다! – Freiermuth

관련 문제