Jump to content

multiple line to 1 line


homer.favenir

Recommended Posts

hi to all,

im keep on solving thi problem, but i cant find any work around over it.

well, i have a string.

  23ABARQUEZ-AGCAOILI, CARMENCITA            IM  CCM PUD            U *OF *THE EAST-PHILIPPINES '80                                        A0044473  1955                                                                          1
                2557 MOWRY AVE #12                       FREMONT              94538-1641 510 793-3722                                                                                                                              2
FAX:                                                                                     510 793-8783                                                                                                                              2
  23ABBOTT, MYLES B                          PD                     U *OF MIAMI-F*L '72                                                    G0025178  1947                                                                          1
                2999 REGENT ST #325                      BERKELEY             94705-2115 925 254-9203                                                                                                                              2
FAX:                                                                                     510 841-5650                                                                                                                              2
                96 DAVIS RD                              ORINDA               94563      925 254-9203                                                                                                                              2
FAX:                                                                                     925 254-1054 *MABBOTTMD@AOL.*COM                                                                                                          2
  23ABELIUK, OSCAR N                         N                      U *OF CHILE-SANTIAGO '74                                               A0035288  1949                                                                          1
                2485 HIGH SCHOOL AVE #101                CONCORD              94520      925 827-0133                                                                                                                              2
FAX:                                                                                     925 827-9216                                                                                                                              2
  23ABRAMS, SHARON L                         DR                     STATE U *OF N*Y SYRACUSE '79                                           G43534    1952 THE PERMANENTE MED GRP                                                   1
                1425 S MAIN ST                           WALNUT CREEK         94596      925 295-4753                                                                                                                              2
  23ABRAMSON, SCOTT A                        N                      MED COL *OF GEORGIA-AUGUSTA '73                                        G039478   1947 THE PERMANENTE MED GRP                                                   1
                27400 HESPERIAN BLVD                     HAYWARD              94545      510 784-4393                                                                                                                              2
FAX:                                                                                     510 784-4990                                                                                                                              2

and i have a script

<html>
<body>

<table border = 1>
<th>Mambers Name</th>
<th>Special Designation</th>
<th>License Number</th>
<th>Medical Group</th>
<th>Address</th>
<?php
$count = 0;
$file = file('ACCMA-RAW.txt');
foreach($file as $line)
{
	$level = substr($line,227,1);

	if($level == 1)
	{
		$name = substr($line,5,40);
		$code1 = substr($line,45,3);
		$code2 = substr($line,49,3);
		$code3 = substr($line,53,3);
		$code4 = substr($line,57,3);
		$code5 = substr($line,61,3);
		$code6 = substr($line,65,3);
		$lic = substr($line,139,;
		$grp = substr($line,154,73);

	?>

		<tr>
			<td><pre><?php echo $name;?></pre>
			<td><pre><?php echo $code1." ".$code2." ".$code3." ".$code4." ".$code5." ".$code6;?></pre>
			<td><pre><?php echo $lic;?></pre>
			<td><pre><?php echo $grp;?></pre>
		</tr>


<?php } $count++;
} echo $count; ?>
</table>

</body>
</html>

but it isnt done yet.

well the required output is, well as you can see there is a number on the last colum of the string (1 and 2 is level). i need all lines with level 1 preceeding by level 2 as 1 record, its like merging multiple lines into 1 lines only.

 

 

 

anyone please.

  ???

thanks

Link to comment
https://forums.phpfreaks.com/topic/116691-multiple-line-to-1-line/
Share on other sites

Abarquez-Agcaoili, Carmencita	Internal Medicine	A0044473		2557 Mowry Ave #12	Fremont	94538-1614	510-793-3722	510-793-8783		U of the East-Philippines '80	1955	
Abarquez-Agcaoili, Carmencita	Critical Care Medicine-Internal Medicine	A0044473		2557 Mowry Ave #12	Fremont	94538-1614	510-793-3722	510-793-8783		U of the East-Philippines '80	1955	
Abarquez-Agcaoili, Carmencita	Pulmonary Disease	A0044473		2557 Mowry Ave #12	Fremont	94538-1614	510-793-3722	510-793-8783		U of the East-Philippines '80	1955	
Abbott, Myles B	Pediatrics	G0025178		2999 Regent St #325	Berkeley	94705-2115	925-254-9203	510-841-5650		U of Miami-FL '72	1947	
Abbott, Myles B	Pediatrics	G0025178		96 Davis Rd	Orinda	94563	925-254-9203	925-254-1054	[email protected]	U of Miami-FL '72	1947	
Abeliuk, Oscar N	Neurology	A0035288		2485 High School Ave #101	Concord	94520	925-827-0133	925-827-9216		U of Chile-Santiago '74	1949	
Abrams, Sharon L	Diagnostic Radiology	G43534	The Permanente Med Grp	1425 S Main St	Walnut Creek	94596	925-295-4753			State U of NY Syracuse '79	1952	
Abramson, Scott A	Neurology	G039478	The Permanente Med Grp	27400 Hesperian Blvd	Hayward	94545	510-784-4393	510-784-4990		Med Col of Georgia-Augusta '73	1947	
Abudayeh, Nabil K	Cardiovascular Disease	G0059072		20126 Stanton Ave #201	Castro Valley	94546	510-886-6878	510-886-0268		U Hlth Sci Chicago Med Schl-IL '85	1958	
Abudayeh, Nabil K	Cardiovascular Disease	G0059072		1022 Murrieta Blvd	Livermore	94550	925-961-8920	925-961-8923		U Hlth Sci Chicago Med Schl-IL '85	1958	
Achanta, Kranthi K	General Surgery	A69021		1860 Mowry Ave #400	Fremont	94538	510-794-4711	510-794-9783		Gandhi Med Col-India '91	1964	

thats the final output, there are still some cases, but first i have to make the script above, then i will go to the next step.tnx

something like this...not tested

 


<html>
<body>

<table border = 1>
<th>Mambers Name</th>
<th>Special Designation</th>
<th>License Number</th>
<th>Medical Group</th>
<th>Address</th>
<?php
$count = 0;
$lastlevel = "";
$file = file('ACCMA-RAW.txt');
foreach($file as $line)
{
	$level = substr($line,227,1);
	if($level == 2){
                                 if($lastlevel == 1) {
                                        continue;
                                 }
                       
                          } else if($level == 1)
	{
		$name = substr($line,5,40);
		$code1 = substr($line,45,3);
		$code2 = substr($line,49,3);
		$code3 = substr($line,53,3);
		$code4 = substr($line,57,3);
		$code5 = substr($line,61,3);
		$code6 = substr($line,65,3);
		$lic = substr($line,139,;
		$grp = substr($line,154,73);

	?>

		<tr>
			<td><pre><?php echo $name;?></pre>
			<td><pre><?php echo $code1." ".$code2." ".$code3." ".$code4." ".$code5." ".$code6;?></pre>
			<td><pre><?php echo $lic;?></pre>
			<td><pre><?php echo $grp;?></pre>
		</tr>


<?php 
               } 
               $lastlevel = $level;
               $count++;
} echo $count; ?>
</table>

</body>
</html>

thanks,

it works nearly fine, i made some adjustment on the script.

<html>
<body>

<table border = 1>
<th>Mambers Name</th>
<th>Special Designation</th>
<th>License Number</th>
<th>Medical Group</th>
<th>Address</th>
<?php
$count = 0;
$lastlevel = "";
$file = file('ACCMA-RAW.txt');
foreach($file as $line)
{
	$level = substr($line,227,1);
	if($level == 2)
	{
		if($lastlevel == 1) 
		{
			$add = substr($line,16,39);
                        }
                       
                } 
	else if($level == 1)
	{
		$name = substr($line,4,40);
		$code1 = substr($line,45,3);
		$code2 = substr($line,49,3);
		$code3 = substr($line,53,3);
		$code4 = substr($line,57,3);
		$code5 = substr($line,61,3);
		$code6 = substr($line,65,3);
		$lic = substr($line,139,;
		$grp = substr($line,154,73);


	?>

		<tr>
			<td><pre><?php echo $name;?></pre>
			<td><pre><?php echo $code1." ".$code2." ".$code3." ".$code4." ".$code5." ".$code6;?></pre>
			<td><pre><?php echo $lic;?></pre>
			<td><pre><?php echo $grp;?></pre>
			<td><pre><?php echo $add;?></pre>
		</tr>


<?php 
               } 
               $lastlevel = $level;
               $count++;
} echo $count; ?>
</table>

</body>
</html>

now i added an address, the address, city, zipcode,  phone and email address are all in the level 2. the name, code, university, license #, birthyear and medical group are all in level 1. i would like to add them both.

my output on your script which i added the address (script above), has an address which is ok, but the address is not align with the right name. it goes to the next row instead of the first row.

 

thanks

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.