search

Home  >  Q&A  >  body text

How to split text in PHP first according to newlines, and then split the contents of each line according to delimiters

123----456----789
000----111----222
222----333----123
比如我要分割这种格式的文本应该怎么写呢
蒲                 1947 days ago1594

reply all(2)I'll reply

  • angryTom

    angryTom2019-07-16 15:58:46

    $pizza  = "piece1----piece2----piece3----piece4----piece5---- piece6";
    $pieces = explode("----", $pizza);
    echo $pieces[1];

    You can try PHP's explode() method to split the string into arrays according to the specified characters.

    reply
    1
  • 蒲

    grateful

    · 2019-07-16 16:48:05
  • Cancelreply