★ wanayoo — archive 1999 http://www.devshed.com/Talk/Forums/Forum5/HTML/001901.htmlNouvelle recherche | Portail wanayoo
DevShed Menu
* DevShed Home
* Developer News
* DevShed Brain Dump




UBBFriend: Email This Page to Someone!
  DevShed Discussion Forums
  PHP
  Strip HTML tags, and save to a seperate array

Post New Topic  Post A Reply
profile | register | preferences | faq | search

next newest topic | next oldest topic
Author Topic:   Strip HTML tags, and save to a seperate array
Chris Pickett
Member
posted July 13, 2000 11:50 AM     Click Here to See the Profile for Chris Pickett   Click Here to Email Chris Pickett     Edit/Delete Message Reply w/Quote
I am trying to take a string, and seperate the HTML code from the string and put it into an array, and then take my string it into several strings of around 110 characters, and then put the HTML back in, does anyone think it can be done, and how?

Chris

Shiju Rajan
Member
posted July 14, 2000 03:35 AM     Click Here to See the Profile for Shiju Rajan   Click Here to Email Shiju Rajan     Edit/Delete Message Reply w/Quote

<<does anyone think it can be done>>

yes,you can do that..

<<
and how?
>>

You will have to play around Regx functions..

give more details here....

------------------
SR -
webshiju.com

"The fear of the LORD is the beginning of knowledge..."

Chris Pickett
Member
posted July 14, 2000 11:38 AM     Click Here to See the Profile for Chris Pickett   Click Here to Email Chris Pickett     Edit/Delete Message Reply w/Quote
Ok, where I work we are trying to put some of the lega forms online, so I took one of the forms scanned it in, and made a text file from it, in the text file I replaced all of the actual form boxes with txt_field, and replaced all of the checkboxes with cbox. I then take that text file into a script that replaces all instances of txt_field and cbox with the HTML forms. This page then passes all of the information to anther page where I am working on arranging it all like it is on the actual doecument, since this is a legal document it must closely match the orignal, so I have had to put every paragraph on one line in the text file, and then split the lines manually, so that I know where the lines end up so I can then number them, the reason I need to strip the HTML is that if I have the code in myt lines it counts the HTML characters, and doesn't split them the way it should some lines are long than others, and some just do two or three actual characters and quit. It's been a total pain to this point, and now I am totally stuck.

Chris

Shiju Rajan
Member
posted July 15, 2000 02:11 AM     Click Here to See the Profile for Shiju Rajan   Click Here to Email Shiju Rajan     Edit/Delete Message Reply w/Quote

<<
so that I know where the lines end up so I can then number them, the reason I need to strip the HTML is that if I have the code in myt lines it counts the HTML characters, and doesn't split them the way it should some lines are long than others, and some just do two or three actual characters and quit.
>>

Chris,
If you can post that code then we can help you in some way...with out seeing the script i can't tell you anything....


------------------
SR -
webshiju.com

"The fear of the LORD is the beginning of knowledge..."

Chris Pickett
Member
posted July 15, 2000 07:13 PM     Click Here to See the Profile for Chris Pickett   Click Here to Email Chris Pickett     Edit/Delete Message Reply w/Quote
Sorry, I forgot to include it in my last post. It is kind of long, and if you need it I can post some of my text file on Monday.

<?
$formfile=file("jus-purchase.txt");
$chars_line = 130;
$fontsize = 1.5;
$fontface = "Arial";
$txt_index = 0;
$cbindex = 0;

// Print Header
$header = file("header.txt");
for($index = 0; $index < count($header); $index++)
{
$txt_pos = strpos($header[$index], "txt_field");
while(is_int($txt_pos))
{
//Replace all txt_field with the replacement values
$header[$index] = substr_replace($header[$index], "$txtbox[$txt_index]", $txt_pos, 9);
$txt_index++;
$txt_pos = strpos($header[$index], "txt_field");
}
print("<FONT SIZE=\"$fontsize\" face=\"$fontface\">$header[$index]<BR></FONT>\n");
}

echo "<TABLE>\n";
for($index=1; $index < count($formfile); $index++)
{
$txt_pos = strpos($formfile[$index], "txt_field");
while(is_int($txt_pos))
{
$formfile[$index] = substr_replace($formfile[$index], "$txtbox[$txt_index]", $txt_pos, 9);
$txt_index++;
$txt_pos = strpos($formfile[$index], "txt_field");
}

$cbox_pos = strpos($formfile[$index], "cbox");

$index2 = $index + 1;
$stringlen=strlen($formfile[$index]);
if($stringlen > $chars_line)
{
$buffer[0] = substr_replace($formfile[$index], "|", $chars_line, 1);
$ex = explode ("|", $buffer[0]);
$spacepos = strrpos($ex[0], " ");
$buffer[0] = substr_replace($formfile[$index], "|", $spacepos, 1);
$ex = explode ("|", $buffer[0]);
$formfile[$index] = $ex[0];

if(strlen($formfile[$index2]) == 1)
{
$buffindex = $index2;
$buff_start = array_slice($formfile, 0, $buffindex);
$buff_end = array_slice($formfile, $buffindex);
$buff_start[] = " ";
$formfile = array_merge($buff_start, $buff_end);
}

$ex[1] .= "$formfile[$index2]";
$formfile[$index2] = $ex[1];

while(is_int($cbox_pos))
{
if($checkb[$cbindex] == "on")
{
$formfile[$index] = substr_replace($formfile[$index], "<INPUT TYPE=\"checkbox\" CHECKED>", $cbox_pos, 4);
}
else
{
$formfile[$index] = substr_replace($formfile[$index], "<INPUT TYPE=\"checkbox\">", $cbox_pos, 4);
}
$cbindex++;
$cbox_pos = strpos($formfile[$index], "cbox");
}


}

print("<TR><TD><FONT SIZE=\"$fontsize\" face=\"$fontface\">$index </TD><TD><FONT SIZE=\"$fontsize\" face=\"$fontface\">$formfile[$index]</TD></TR>\n");
}
echo "</TABLE>";
?>

Chris

Chris Pickett
Member
posted July 15, 2000 07:15 PM     Click Here to See the Profile for Chris Pickett   Click Here to Email Chris Pickett     Edit/Delete Message Reply w/Quote
The main problem with the code is that it will chop the sentences off in the middle of the HTML tags, and if it doesn't do that, the senteces will be shorter simply because it is counting the HTML anlong with the actual characters.

Chris

Chris Pickett
Member
posted July 17, 2000 11:00 AM     Click Here to See the Profile for Chris Pickett   Click Here to Email Chris Pickett     Edit/Delete Message Reply w/Quote
Here is a snippet of the text file, it has the txt_field and the cbox in it, also some HTML to make it bold, so it may not work well on this board.

<B>5. METHOD OF PAYMENT: (Circle appropriate paragraph letter)</B>

<B>A. cbox CASH:</B> The entire purchase price shall be paid in cash. No financing is required.

<B>B. cbox NEW MORTGAGE:</B> Completion of this transaction shall be contingent upon the Buyer's ability to obtain a (cbox Conventional) (cbox Insured Conventional) (cbox 100% Loan to Value) (cbox FHA) (cbox VA) (cbox Other: txt_field) first mortgage loan for txt_field % of purchase price payable in not less than txt_field years, with an original rate of interest not to exceed txt_field % per annum and not to exceed txt_field points. Buyer shall pay all costs of obtaining financing, except txt_field

<B>C.</B> Notwithstanding any other provisions of this Agreement, any inspections and charges required to be made and charged to Buyer or Seller by FHA or VA, mortgage insurer, or closing agent, shall be made and charged in accordance with their prevailing rules or regulations and shall supercede any provisions of this Agreement.

All times are MST (US)

next newest topic | next oldest topic

Administrative Options: Close Topic | Archive/Move | Delete Topic
Post New Topic  Post A Reply
Hop to:

Contact Us | DevShed.com

Copyright © 1997-2000 ngenuity. All rights reserved.

Powered by: Ultimate Bulletin Board, Version 5.41a
© Infopop Corporation (formerly Madrona Park, Inc.), 1998 - 1999.