两个URL字符串之间的差异

时间:2013-06-22 13:39:36

标签: php string

我建立

define('SITE_URL', siteURL()); //returns http://example.com/dir/
define('CKEDITOR', SITE_URL.'plugins/ckeditor/ckeditor.js');

SITE_URLfull URL又名http://example.com/dir/plugins/ckeditor/ckeditor.js之间查找'差异'的字符串操作是什么,以便我只返回{{1部分?

2 个答案:

答案 0 :(得分:2)

str_replace($site_url, '', $fullurl);

答案 1 :(得分:0)

这是你的答案

function siteURL()
{
    return "http://example.com/dir/";
}

define('SITE_URL', siteURL()); //returns http://example.com/dir/
define('CKEDITOR', SITE_URL.'plugins/ckeditor/ckeditor.js');

// ignore the previous code is just to emulate your constants and functions
// the answer is the following line:

echo str_replace(SITE_URL,'',CKEDITOR);

这里的工作示例:http://3v4l.org/svTYm