[ create a new paste ] login | about

Link: http://codepad.org/nBCj38zT    [ raw code | output | fork ]

PHP, pasted on Jan 24:
1
2
3
4
5
6
7
8
9
10
11
12
13
<?php
function uri_to_array($uri){
  $result = array();
  
  parse_str(substr($uri, strpos($uri, '?') + 1), $result);
  list($result['user'], $result['page']) = explode('/', trim($uri, '/'));
  
  return $result;
}

print_r(
  uri_to_array('/admin/stock/?sub_page=products&action=add')
);


Output:
1
2
3
4
5
6
7
Array
(
    [sub_page] => products
    [action] => add
    [page] => stock
    [user] => admin
)


Create a new paste based on this one


Comments: