Created
June 18, 2013 09:29
-
-
Save openprojdev/5803965 to your computer and use it in GitHub Desktop.
PHP CDN hostnames based on circular array shift, useful to distribute static content via multi hostnames serving the same content i.e increase concurrent downloads by browsers
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $cdnHosts = array( //declared in an global config | |
| 'h1.hostname.com', | |
| 'h2.hostname.com', | |
| 'h3.hostname.com', | |
| 'h4.hostname.com' | |
| ); | |
| /** | |
| * | |
| * cdnHostNames | |
| * | |
| * @params array $cdnHosts containing all the hostnames | |
| * @return string the first string value of the circular shifted array | |
| */ | |
| function cdnHostNames(&$cdnHosts) { | |
| $cdnHosts = array_merge( array_slice($cdnHosts, 1), array_slice($cdnHosts, 0, 1) ) ; | |
| return $cdnHosts[0]; | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment