3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php /** * Returns list of subdomains * @param string $domain * @return array */ function getAllSubDomain($domain) { //strip '<prefix>:' first $dpos = strpos($domain, ':'); if ($dpos !== false) { $domain = substr($domain, $dpos+1); } else { $domain = $domain; } $domainParts = explode('.', str_replace("'", '', $domain)); $ret = array(); for ($off = sizeof($domainParts) -1; $off >= 0; $off--) { $ret[] = implode('.', array_slice($domainParts, $off)); } return $ret; } $subDomains = getAllSubdomain('oxadmin.pr.citeeze.com'); var_export($subDomains); echo "\n"; $queryPart = $q = "SELECT modifiers m" . " FROM delivery_host_modifiers" . " WHERE host IN ('" . implode("','", $subDomains) . "')" . " ORDER BY LENGTH(host) " ; var_export($queryPart); $result = json_decode('[{ "id": 78852, "domain": "local.dev.citeeze.com", "categories": null, "added": "2014-12-04 06:35:38", "updated": "2014-12-10 21:23:34", "visible": 1, "user_added": 0, "mobile": 0, "requests": 0, "completion": 0.00 }, { "id": 89652, "domain": "www.citeeze.com", "categories": null, "added": "2014-12-04 06:47:25", "updated": "2014-12-10 21:29:10", "visible": 1, "user_added": 0, "mobile": 0, "requests": 0, "completion": 0.00 }, { "id": 356163, "domain": "citeeze.com", "categories": null, "added": "2015-01-20 13:42:50", "updated": "2015-01-20 13:42:50", "visible": 1, "user_added": 1, "mobile": 0, "requests": 0, "completion": 0.00 }, { "id": 2739296, "domain": "dev.citeeze.com", "categories": null, "added": "2016-04-18 05:11:23", "updated": "2016-04-18 05:11:23", "visible": 0, "user_added": 0, "mobile": 0, "requests": 0, "completion": 0.00 }, { "id": 4399187, "domain": "adunit.brendan.citeeze.com", "categories": null, "added": "2016-08-08 17:26:26", "updated": "2016-08-08 17:26:26", "visible": 1, "user_added": 0, "mobile": 0, "requests": 0, "completion": 0.00 }, { "id": 5862092, "domain": "tools.brendan.citeeze.com", "categories": null, "added": "2016-09-19 21:22:07", "updated": "2016-09-19 21:22:07", "visible": 1, "user_added": 0, "mobile": 0, "requests": 0, "completion": 0.00 }, { "id": 6335525, "domain": "oxadmin.pr.citeeze.com", "categories": null, "added": "2017-01-09 16:53:54", "updated": "2017-01-09 16:53:54", "visible": 0, "user_added": 0, "mobile": 0, "requests": 0, "completion": 0.00 }, { "id": 6335537, "domain": "pr.citeeze.com", "categories": "", "added": "2017-07-11 12:53:18", "updated": "2017-07-11 12:53:25", "visible": 0, "user_added": 0, "mobile": 0, "requests": 0, "completion": 0.00 }, { "id": 6335540, "domain": "test.oxadmin.prciteeze.com", "categories": null, "added": "2017-07-11 11:56:42", "updated": "2017-07-11 11:56:42", "visible": 0, "user_added": 0, "mobile": 0, "requests": 0, "completion": 0.00 } ]'); var_export($result);
Output for 5.4.44
array ( 0 => 'com', 1 => 'citeeze.com', 2 => 'pr.citeeze.com', 3 => 'oxadmin.pr.citeeze.com', ) 'SELECT modifiers m FROM delivery_host_modifiers WHERE host IN (\'com\',\'citeeze.com\',\'pr.citeeze.com\',\'oxadmin.pr.citeeze.com\') ORDER BY LENGTH(host) 'array ( 0 => stdClass::__set_state(array( 'id' => 78852, 'domain' => 'local.dev.citeeze.com', 'categories' => NULL, 'added' => '2014-12-04 06:35:38', 'updated' => '2014-12-10 21:23:34', 'visible' => 1, 'user_added' => 0, 'mobile' => 0, 'requests' => 0, 'completion' => 0, )), 1 => stdClass::__set_state(array( 'id' => 89652, 'domain' => 'www.citeeze.com', 'categories' => NULL, 'added' => '2014-12-04 06:47:25', 'updated' => '2014-12-10 21:29:10', 'visible' => 1, 'user_added' => 0, 'mobile' => 0, 'requests' => 0, 'completion' => 0, )), 2 => stdClass::__set_state(array( 'id' => 356163, 'domain' => 'citeeze.com', 'categories' => NULL, 'added' => '2015-01-20 13:42:50', 'updated' => '2015-01-20 13:42:50', 'visible' => 1, 'user_added' => 1, 'mobile' => 0, 'requests' => 0, 'completion' => 0, )), 3 => stdClass::__set_state(array( 'id' => 2739296, 'domain' => 'dev.citeeze.com', 'categories' => NULL, 'added' => '2016-04-18 05:11:23', 'updated' => '2016-04-18 05:11:23', 'visible' => 0, 'user_added' => 0, 'mobile' => 0, 'requests' => 0, 'completion' => 0, )), 4 => stdClass::__set_state(array( 'id' => 4399187, 'domain' => 'adunit.brendan.citeeze.com', 'categories' => NULL, 'added' => '2016-08-08 17:26:26', 'updated' => '2016-08-08 17:26:26', 'visible' => 1, 'user_added' => 0, 'mobile' => 0, 'requests' => 0, 'completion' => 0, )), 5 => stdClass::__set_state(array( 'id' => 5862092, 'domain' => 'tools.brendan.citeeze.com', 'categories' => NULL, 'added' => '2016-09-19 21:22:07', 'updated' => '2016-09-19 21:22:07', 'visible' => 1, 'user_added' => 0, 'mobile' => 0, 'requests' => 0, 'completion' => 0, )), 6 => stdClass::__set_state(array( 'id' => 6335525, 'domain' => 'oxadmin.pr.citeeze.com', 'categories' => NULL, 'added' => '2017-01-09 16:53:54', 'updated' => '2017-01-09 16:53:54', 'visible' => 0, 'user_added' => 0, 'mobile' => 0, 'requests' => 0, 'completion' => 0, )), 7 => stdClass::__set_state(array( 'id' => 6335537, 'domain' => 'pr.citeeze.com', 'categories' => '', 'added' => '2017-07-11 12:53:18', 'updated' => '2017-07-11 12:53:25', 'visible' => 0, 'user_added' => 0, 'mobile' => 0, 'requests' => 0, 'completion' => 0, )), 8 => stdClass::__set_state(array( 'id' => 6335540, 'domain' => 'test.oxadmin.prciteeze.com', 'categories' => NULL, 'added' => '2017-07-11 11:56:42', 'updated' => '2017-07-11 11:56:42', 'visible' => 0, 'user_added' => 0, 'mobile' => 0, 'requests' => 0, 'completion' => 0, )), )