Created
March 23, 2015 15:23
-
-
Save gfargo/f0fa5ff3e7b4cba7b151 to your computer and use it in GitHub Desktop.
Easy Array Explode | Map Maker WP Plugin
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 | |
| /* | |
| Do Shortcode | |
| http://codex.wordpress.org/Function_Reference/do_shortcode | |
| StackOverflow - Better Way to Explode String | |
| http://stackoverflow.com/questions/7355301/a-better-way-to-explode-twice-in-php | |
| */ | |
| # Put on Single Page for Custom Post Type = Game | |
| $selectedField = functionToGetCategoryChosen(); | |
| echo getFieldMap($selectedField); | |
| # Can Put this in your Functions.php | |
| function getFieldMap($selectedField) { | |
| $inputStringFromAdmin = "Westford:501202;Burlington:50232;Williston:213210"; | |
| preg_match_all('/([^:]*?):([^;]*);?/', $input, $matches); | |
| $output = array_combine($matches[1], $matches[2]); | |
| return do_shortcode( '[mapmaker id="' . $output[$selectedField] . '" other parameters = bla bla ]' ); | |
| } | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment