Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $url = $_GET['url'];
- $rules = array(array('/article\/([0-9])/', '/articles/show/$1'));
- $i = 0;
- $found = false;
- //We check if we haven't found any rule that matches to what we want and that we haven't went beyond the array index
- while(!$found && !empty($rules) && $i < count($rules))
- {
- if(preg_match($rules[$i][0], $url))
- {
- $url = preg_replace($rules[$i][0], $rules[$i][1], $url);
- $found == true;
- }
- $i++;
- }
- //....Do what you want with the url
Advertisement
Add Comment
Please, Sign In to add comment