How should I perform multiple explode cutting and combination?

Source: Internet
Author: User
How should I perform multiple explode cutting and combination? This post was last written by lovepzt at 2015-01-0919: 16: 09 edit reference $ ayouku $ tudou $ down $ B first set $ abcd second set $ abcd third set $ abcd fourth set $ abcd fifth set $ abcd $ episode 1 $ abcd multiple explode cutting and combination, what should I do?

This post was last edited by lovepzt at 19:16:09 on

Reference
$ A = 'youku $ tudou $ down'
$ B = 'Episode 1 $ abcd
Episode 1 $ abcd
Episode 2 $ abcd
Episode 3 $ abcd
Episode 4 $ abcd
Episode 5 $ abcd $ episode 1 $ abcd
Episode 1 $ abcd
Episode 2 $ abcd
Episode 3 $ abcd
Episode 4 $ abcd
Episode 5 $ abcd $ episode 1 $ abcd
Episode 1 $ abcd
Episode 2 $ abcd
Episode 3 $ abcd
Episode 4 $ abcd
Episode 5 $ abcd'


Yes $ split
Last $ or line feed segmentation
Finally, you need to get
  • Youku

  • Episode 1
    Second Set
    Episode 3
    Episode 4
    Episode 5

  • Tudou

  • Episode 1
    Second Set
    Episode 3
    Episode 4
    Episode 5

  • Down

  • Episode 1
    Second Set
    Episode 3
    Episode 4
    Episode 5
    ------ Solution ----------------------
    $a = explode('$$$', $a);
    $b = explode('$$$', $b);
    foreach($a as $i=>$r) {
    echo "
  • $r
  • \n";
    foreach(explode("\n", $b[$i]) as $j=>$v) {
    $t = explode('$', trim($v));
    printf("%s\n", $i+1, $j+1, $t[0]);
    }
    }
  • Youku

  • Episode 1
    Episode 1
    Second Set
    Episode 3
    Episode 4
    Episode 5
  • Tudou

  • Episode 1
    Episode 1
    Second Set
    Episode 3
    Episode 4
    Episode 5
  • Down

  • Episode 1
    Episode 1
    Second Set
    Episode 3
    Episode 4
    Episode 5


    But your data is supposed to be like this.
    $ A = 'youku $ tudou $ down ';
    When bw.'episode 1 was just 1.html
    Episode 2 pai1_2.html
    Episode 3, Chapter 3.html
    Episode 4, chapter 3.html
    Chapter 5 5.html######2_1.html
    Episode 2_2.html
    Episode 3 pai2_3.html
    42.162_4.html
    Episode 2_5.html#### episode 3_1.html
    Episode 2 3_2.html
    3_3.html
    3_4.html
    Fifth Episode 3_5.html ';

    $ A = explode ('$', $ );
    $ B = explode ('$', $ B );
    Foreach ($ a as $ I =>$ r ){
    Echo"
  • $ R
  • \ N ";
    Foreach (explode ("\ n", $ B [$ I]) as $ v ){
    $ T = explode ('$', trim ($ v ));
    Echo "$ t [0] \ n ";
    }
    }
  • Youku

  • Episode 1
    Second Set
    Episode 3
    Episode 4
    Episode 5
  • Tudou

  • Episode 1
    Second Set
    Episode 3
    Episode 4
    Episode 5
  • Down

  • Episode 1
    Second Set
    Episode 3
    Episode 4
    Episode 5

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.