This project just got dumped on me.
I have a text file that has several lines in it. Like this:
<cat:8850>
<begad:1279434><logo:><togurl:y><togemail:y><bkgrdtog:n><addr:ATTN:CHARLIE><zip:50613>'05 Pontiac Grand Am SE, 35,200 mi., $9,600 or best reasonable offer. Contact Charlie at 319-266-XXX<endad>
<cat:8850>
<begad:1278968><logo:><togurl:y><togemail:y><bkgrdtog:n><addr:34304 160TH ST.><zip:50613>'07 GRAND Prix, red, GM certified, 35,000 mi. Leather, sunroof, remote start. Laid off. $14,000 Must sell. 319-215-XXX<endad>
I need to get the top line of these entries with the rest of the string and repeat them. Like this:
<cat:8850><begad:1279434><logo:><togurl:y><togemail:y><bkgrdtog:n><addr:ATTN:CHARLIE><zip:50613>'05 Pontiac Grand Am SE, 35,200 mi., $9,600 or best reasonable offer. Contact Charlie at 319-266-XXXX<endad>
<cat:8850><begad:1278968><logo:><togurl:y><togemail:y><bkgrdtog:n><addr:34304 160TH ST.><zip:50613>'07 GRAND Prix, red, GM certified, 35,000 mi. Leather, sunroof, remote start. Laid off. $14,000 Must sell. 319-215-XXXX<endad>
I can get them into one continuous string, but that's not really working for me. Here's what I have so far:
$ourFileName = "testFile.txt";
$ourFileHandle = fopen($ourFileName, 'rb') or die("can't open file");
$numberd = 0;
while (!feof($ourFileHandle) ) {
$line_of_text = fgets($ourFileHandle, 4062);
$new_string = preg_replace("/[^a-zA-Z0-9\s]/", "", $line_of_text);
$parts = explode('\n', $new_string);
$adcopy = $parts[0] . $parts[1];
$numberd++;
echo $adcopy . "|";
}
fclose($ourFileHandle);
Any help would be super. Thank you.