一个变量中的两个变量值是可能的



我的代码:

$url = "http://www.google.com/test";
$parseurl = parse_url($url);
$explode = explode('.', $parseurl['host']);
$arrayreverse = array_reverse($explode);
foreach(array_values($arrayreverse) as $keyvalue) {
    $result[] = $keyvalue;
}
$implode = implode('.', $result);
...

我有兴趣在 $ implode 结果中的一个变量中具有值,如果将路径设置为 $ parseurl ...我该怎么做?

编辑:

我希望 $implode + and(if isset $parseurl['path']) ; 的值在 1 个变量中,但我无法弄清楚如何统一它们。

这是你想要的吗?

$newurl = $implode . (isset($parseurl['path']) ? $parseurl['path'] : '');

它使用条件运算符返回路径或空字符串,并将其连接到$implode 上。

最新更新