Guest User

Untitled

a guest
Sep 20th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. <?php
  2. function parseCacheControl($header)
  3. {
  4. $cacheControl = array();
  5. preg_match_all('#([a-zA-Z][a-zA-Z_-]*)\s*(?:=(?:"([^"]*)"|([^ \t",;]*)))?#', $header, $matches, PREG_SET_ORDER);
  6. foreach ($matches as $match) {
  7. $cacheControl[strtolower($match[1])] = isset($match[2]) && $match[2] ? $match[2] : (isset($match[3]) ? $match[3] : true);
  8. }
  9.  
  10. return $cacheControl;
  11. }
  12.  
  13. var_dump(parseCacheControl('no-store& private=test, no-cache="a,b,c"'));
  14.  
  15. $start = microtime(true);
  16. for ($i=0; $i<10000; $i++) {
  17. parseCacheControl('no-store, private=test, no-cache="a,b,c"');
  18. }
  19. var_dump(microtime(true) - $start);
Add Comment
Please, Sign In to add comment