Created
January 6, 2015 00:10
-
-
Save ricardosiri68/0391be5d236ed807a506 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $expresion = '/page=[0-9]+/'; | |
| $pages = [ | |
| "http://localhost/ejemplo/pagina?page=1" => "http://localhost/ejemplo/pagina?page=2", | |
| "http://localhost/ejemplo/pagina?page=1&foo=20" => "http://localhost/ejemplo/pagina?page=2&foo=20", | |
| "http://regex101.com/?page=1" => "http://regex101.com/?page=2", | |
| "http://regex101.com/?page=1&foo=20" => "http://regex101.com/?page=2&foo=20" | |
| ]; | |
| $page = 2; | |
| foreach ($pages as $test => $control) { | |
| $result = preg_replace($expresion, "page=$page", $test); | |
| if ($result <> $control) { | |
| echo "<b>" . $result . "</b> - " . $control . "</br>"; | |
| } else { | |
| echo "<b>ok</b> - $test </br>"; | |
| } | |
| } | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment