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]);
}
}
YoukuEpisode 1
Episode 1
Second Set
Episode 3
Episode 4
Episode 5
TudouEpisode 1
Episode 1
Second Set
Episode 3
Episode 4
Episode 5
DownEpisode 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 ";
}
}
YoukuEpisode 1
Second Set
Episode 3
Episode 4
Episode 5
TudouEpisode 1
Second Set
Episode 3
Episode 4
Episode 5
DownEpisode 1
Second Set
Episode 3
Episode 4
Episode 5