php - 从php中的字符串中删除http和https

标签 php arrays preg-match

我有几个网址,例如

https://example.com/
http://example.com/

我只想要“example.com”作为字符串

我想删除

https:// and http://



所以我采取了这样的阵列,
$removeChar = ["https://", "http://", "/"];

删除这些的正确方法是什么?

最佳答案

这对我有用,

$http_referer = str_replace($removeChar, "", "https://example.com/");

关于php - 从php中的字符串中删除http和https,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37415308/

相关文章:

php - 将按钮和链接添加到占位符中的问题

javascript - 在 javascript 对象定义中连接字符串

php mysqli_fetch_array 返回 $name 结果为 'name'

php - 用于非本地化目的的 Unicode 标识符(函数名称)是否可取?

php - mysqli,OOP 与过程

php - 如何使用 RewriteRule 来执行不可见的搜索查询?

javascript - 当相等时合并数组的连续项

php - preg_match() 和多字节字符

PHP preg_match_all 搜索和替换

regex - Preg-match 返回错误值?