Created
March 10, 2011 21:20
-
-
Save crynobone/864952 to your computer and use it in GitHub Desktop.
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 | |
$string_create = 'create_some_long_tablename'; | |
$string_add = 'add_some_tablename_to_other_long_table_name'; | |
function get($string) { | |
$string = str_replace(array('create_', 'add_','_to_'), array('create-', 'add-', '-to-'), $string); | |
if (preg_match('/^(create|add)\-([A-Za-z0-9\_]*)(\-to\-)?([A-Za-z0-9\_]*)?$/i', $string, $matches)) { | |
if ($matches[1] == 'create') { | |
echo $matches[2]; | |
} | |
else if ($matches[1] == 'add') { | |
echo $matches[2] . ' to ' . $matches[4]; | |
} | |
} | |
else { | |
echo 'failed'; | |
} | |
print '<br />'; | |
} | |
get($string_create); | |
get($string_add); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment