Skip to content

Instantly share code, notes, and snippets.

@ZurabWeb
Created October 6, 2023 12:34
Show Gist options
  • Save ZurabWeb/0b8d1c25534b2d340e85819f4b434f2b to your computer and use it in GitHub Desktop.
Save ZurabWeb/0b8d1c25534b2d340e85819f4b434f2b to your computer and use it in GitHub Desktop.
Code golf 10/6/2023
<?php
$subdomain = 'a.b.c.d';
$parts = explode('.', $subdomain);
$resp = [];
while (count($parts) > 0) {
$resp[] = implode('.', $parts);
array_shift($parts);
}
print_r($resp);
@ZurabWeb
Copy link
Author

ZurabWeb commented Oct 6, 2023

Array ( [0] => a.b.c.d [1] => b.c.d [2] => c.d [3] => d )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment