php split string based on pattern

前端 未结 2 1669
甜味超标
甜味超标 2021-01-26 00:48

I have a string like this:

2234323,23,23,44,433;3,23,44,433;23,23,44,433;23,23,44,433;4534453,23,23,44,433;
3,23,44,433;23,23,44,433;23,23,44,433
7545455,23,23,4         


        
2条回答
  •  不知归路
    2021-01-26 01:39

    You could do a find and replace on numbers that are seven digits long, to insert a token that you can use to split. The output may need a little extra filtering to get to your desired format.

    Output:

    array (
      1 => '2234323,23,23,44,433;3,23,44,433;23,23,44,433;23,23,44,433;',
      2 => '4534453,23,23,44,433;
    3,23,44,433;23,23,44,433;23,23,44,433
    ',
      3 => '7545455,23,23,44,433;3,23,44,433;23,23,44,433;23,23,44,433',
    )
    

提交回复
热议问题