Created
December 10, 2013 17:46
-
-
Save joubertredrat/7894852 to your computer and use it in GitHub Desktop.
Conceitual idea about switch and regex
This file contains 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 | |
$str = '[0710:020602938:7041]'; | |
preg_switch($str) { | |
case '/^(\[)[A-Z0-9]{4}:(' . rand(10000,29999) . '|' . rand(50000,99999) . '):[A-z]{3}(\])(.*)+/': | |
/* ... */ | |
break; | |
case '/^(\[)[A-Z0-9]{4}:[0-9]{9}:[0-9]{4}(\])+/': | |
/* ... */ | |
break; | |
default: | |
/* ... */ | |
break; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment