Reputation: 117
My code:
$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);
...
I'm interested to have values in one variable from $implode
result and the result if isset the path from $parseurl
... how can I do that ?
EDIT:
I want the values of $implode + and(if isset $parseurl['path'])
; to be in 1 variable but I can't figure out how to unite them.
Upvotes: 0
Views: 79
Reputation: 782295
Is ths what you want?
$newurl = $implode . (isset($parseurl['path']) ? $parseurl['path'] : '');
It uses the conditional operator to return either the path or an empty string, and concatenate that onto $implode
.
Upvotes: 3