php - Extract strings inside shortcodes -
i have string may contain shortcodes such this string [e]with[/e] multiple [e]shortcodes[/e]
. want extract strings: "with" , "shortcodes" array.
$string_with_shortcodes = "this string [e]with[/e] multiple [e]shortcodes[/e]";
how can this?
$count = preg_match_all("\01\[e\](.*?)\[/e\]\01", $string_with_shortcodes, $matches); $shortcodes_array = $matches[1];
based on example gave,
$matches[0]
contain:array("[e]with[/e]","[e]shortcodes[/e]")
$matches[1]
contain:array("with","shortcodes")
Comments
Post a Comment