php regex split string by [%%%]

前端 未结 2 1220
春和景丽
春和景丽 2021-01-21 07:17

Hi I need a preg_split regex that will split a string at substrings in square brackets.

This example input:

$string = \'I have a string cont         


        
2条回答
  •  我在风中等你
    2021-01-21 07:31

    I think this is what you are looking for:

    $array = preg_split('/(\[.*?\])/', $string, null, PREG_SPLIT_DELIM_CAPTURE);
    

提交回复
热议问题