Get all matches from string that start with and end, using php

后端 未结 2 779
悲&欢浪女
悲&欢浪女 2021-01-08 01:10

How would I use PHP to extract everything in between [startstring] and [endstring] from this string:

[startstring]hello = guys[ends         


        
2条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-08 01:58

    Try with preg_match_all:

    preg_match_all('/\[startstring\](.*?)\[endstring\]/', $input, $matches);
    var_dump($matches);
    

提交回复
热议问题