Finding placeholders and put then in an array
问题 In my string I have place holders like: ##NEWSLETTER## , ##FOOTER# ##GOOGLEANALYTICS## etc. Each of those placeholders is delimited by: ## I want to find each of thos placeholders and put them in an array. The tricky part is that what's inside the ## delimiters can be anything. 回答1: Try this: <?php $s = "asdff ##HI## asdsad ##TEST## asdsadsadad"; preg_match_all("~##([^#]+)##~", $s, $result); var_dump($result[1]); prints: array(2) { [0]=> string(2) "HI" [1]=> string(4) "TEST" } 回答2: you can