Skip to content

Instantly share code, notes, and snippets.

@gfargo
Created March 23, 2015 15:23
Show Gist options
  • Select an option

  • Save gfargo/f0fa5ff3e7b4cba7b151 to your computer and use it in GitHub Desktop.

Select an option

Save gfargo/f0fa5ff3e7b4cba7b151 to your computer and use it in GitHub Desktop.
Easy Array Explode | Map Maker WP Plugin
<?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