Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function parseCacheControl($header)
- {
- $cacheControl = array();
- preg_match_all('#([a-zA-Z][a-zA-Z_-]*)\s*(?:=(?:"([^"]*)"|([^ \t",;]*)))?#', $header, $matches, PREG_SET_ORDER);
- foreach ($matches as $match) {
- $cacheControl[strtolower($match[1])] = isset($match[2]) && $match[2] ? $match[2] : (isset($match[3]) ? $match[3] : true);
- }
- return $cacheControl;
- }
- var_dump(parseCacheControl('no-store& private=test, no-cache="a,b,c"'));
- $start = microtime(true);
- for ($i=0; $i<10000; $i++) {
- parseCacheControl('no-store, private=test, no-cache="a,b,c"');
- }
- var_dump(microtime(true) - $start);
Add Comment
Please, Sign In to add comment