Question: This code works:

```
    $host = parse_url('http://www.cc.joomla.mywebsite.net/paypal.com/myspace.com/login.php', PHP_URL_HOST);

    $host_names = explode(".", $host);
    print_r($host_names);
    echo "<br>";
    $l = array_slice($host_names, -3);
    print_r($l);
    echo "<br>";

    $subdomain = implode(".", $l);
    echo $subdomain;    //final result

```

Is it possible to combine function in one line for example like this:

```
$subdomain = implode(array_slice (explode(".", $host)($host_names, -3)(".", $l);

```

The example above does not worked. I think I have seen it before where you can combine function.

Thanks in advance for any help.

Answer: 
Just substitute each variable with the expression that you assign to it:

```
$host_names = explode(".", $host);
$l = array_slice($host_names, -3);

```

becomes 

```
$l = array_slice(explode(".", $host), -3);

```

Then

```
$l = array_slice(explode(".", $host), -3);
$subdomain = implode(".", $l);

```

becomes

```
$subdomain = implode(".", array_slice(explode(".", $host), -3));

```
You can chain funktions "like" that. But if you don't take care they care getting unreadably. Like yours and then errors are difficult to be found:

```
implode(array_slice (explode(".", $host)/* this is not a valid function call */($host_names, -3) /* same here*/ (".", $l);

```

There are so many function calls that you really don't want them all into one line. Its unreadable.

You probably want to write your own function.:
<http://php.net/manual/en/functions.user-defined.php>