#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    59
    Rep Power
    15
    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
  2. #2
  3. .Net Developer
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2000
    Location
    London
    Posts
    987
    Rep Power
    15

    <<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..."
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    59
    Rep Power
    15
    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
  6. #4
  7. .Net Developer
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2000
    Location
    London
    Posts
    987
    Rep Power
    15

    <<
    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..."
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    59
    Rep Power
    15
    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
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    59
    Rep Power
    15
    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
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    59
    Rep Power
    15
    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.

Similar Threads

  1. Cleaning up user provided html
    By crysc in forum Perl Programming
    Replies: 13
    Last Post: January 18th, 2004, 10:17 PM

IMN logo majestic logo threadwatch logo seochat tools logo