Advertisement
Tarlyun

turi class

Mar 4th, 2012
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.61 KB | None | 0 0
  1. <?php
  2.  
  3. class turi {
  4.  
  5.     public static function uri_to_assoc($uri = '')
  6.     {
  7.         $query_string = array();
  8.         foreach ($uri as $val)
  9.         {
  10.             $temp = explode(':', $val);
  11.            
  12.             if (isset($temp[2]))
  13.             {
  14.                 $key = $temp[0];
  15.                 unset($temp[0]);
  16.                 $query_string[$key] = $temp;
  17.             }
  18.             elseif(isset($temp[1]))
  19.             {
  20.                 $query_string[$temp[0]] = $temp[1];
  21.             }
  22.         }
  23.  
  24.         return $query_string;
  25.     }
  26.    
  27.  
  28.    
  29.     public static function assoc_to_uri($assoc = array())
  30.     {
  31.         $temp = array();
  32.         foreach ($assoc as $key => $val)
  33.         {
  34.             $temp[]=$key.':'.implode(':', (array)$val);
  35.         }
  36.  
  37.         return implode('/', $temp);
  38.     }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement