I have 2 bulks of text: Trunk, and Card. Trunk has about 100 lines, and Card has 3. The 3 lines in Card exist in Trunk, but they aren't directly below eachother.
What I'm trying to do is remove each line of Card from the string Trunk.
What came to mind is exploding Card into an Array and using a for each in
loop, like in AS3, but that didn't work like planned. Here's my attempt:
$zarray = explode("
", $card); //Exploding the 3 lines which were seperated by linebreaks into an array
foreach ($zarray as $oneCard) //for each element of array
{
$oneCard.= "
"; //add a linebreak at the end, so that when the text is removed from Trunk, there won't be an empty line in it.
print "$oneCard stuff"; //Strangely outputs all 3 elements of the array seperated by , instead of just 1, like this:
//card1card2card3 stuff
$zard = preg_replace("/$oneCard/i", "", $trunx, 1);//removes the line in Card from Trunk, case insensitive.
$trunx = $zard; //Trunk should now be one line shorter.
}
So, how can I use the foreach loop so that it replaces properly, and uses 1 element each time, instead of all of them in one go?