Split text into two columns

Ask a Question related to PHP Development, Design and Development.

  1. #1

    Default Split text into two columns

    Hi

    I want to be able to split the contents of a text field into two or maybe
    three columns. The text field contains text AND HTML mark-up.

    My initial thought was to find the middle character and then go to the
    nearest space and split the text that way, but it sometimes splits in the
    middle of an HTML tag: not pretty!

    My next idea was to strip the HTML tags from the text and then split it up
    and then reapply the HTML tags, but I am not sure this would work either.

    Has anyone come across this problem and do you have a solution or know of
    one? I would really appreciate it.

    Thanks

    Tim


    Tim Guest

  2. Similar Questions and Discussions

    1. how to split continuous text in a variable into two text-variables...?
      Hi, i have a little problem. i need to split a continuous text-variable into two text-variables but in whole words! so i can show these two...
    2. Dynamic text fields. Continuing text over columns
      Hi I'm doing a mock up news paper article over 4 columns in flash mx and the text loads in dynamically. I have 4 dynamic text boxes sitting side...
    3. Split Text Block into Paragraphs
      I have this large text block, but I would like to split it into smaller ones by a number of characters. It needs to _split at whole words_, and not...
    4. seperating columns in a text box into multiple text boxes?
      Berney: You probably are better off doing this separating in the query data source for your form. You can use string commands to find which...
    5. Can we split content region into two columns?
      Folks, Does there exist a way to create CSS that makes a single block of text display in two columns? Warm regards, Steve Perth, Western...
  3. #2

    Default Re: Split text into two columns

    "Tim" <tjccowan@hotmail.com> wrote
    in message news:<lwlSa.9636$104.1068452@news20.bellglobal.com >...
    >
    > I want to be able to split the contents of a text field into
    > two or maybe three columns. The text field contains text AND
    > HTML mark-up.
    First of all, understand that you will NOT be able to do this
    as precisely as you would on a printed page. In particular,
    there is no way to enforce smooth transition from one column
    to another in the middle of a sentence.
    > My initial thought was to find the middle character and then
    > go to the nearest space and split the text that way, but it
    > sometimes splits in the middle of an HTML tag: not pretty!
    How about finding the <p>, <h?>, or <?l> tag most closely following
    the middle character?

    Cheers,
    NC
    Nikolai Chuvakhin Guest

  4. #3

    Default Re: Split text into two columns

    Tim écrivit:
    > I want to be able to split the contents of a text field into two or
    > maybe three columns. The text field contains text AND HTML mark-up.
    >
    > My initial thought was to find the middle character and then go to the
    > nearest space and split the text that way, but it sometimes splits in
    > the middle of an HTML tag: not pretty!
    function split_pos($text) {

    /* find middle space in text */
    $mid = (int) strlen($text)/2 - 1;
    $cut = strpos($text , ' ' , $mid);
    $part1= substr($text , 0 , $cut + 1);

    $pos1 = strrpos($part1 , '<');
    $pos2 = strrpos($part1 , '>');
    if (($pos1 < $pos2) or ($pos1 === False))
    return $cut; */ no html tag around */

    $pos3 = strpos($text , '>' , $cut1 + 1);
    if($pos3 !== False)
    return $pos3; */ end of middle html tag */
    else return $cut; */ unbalancing < > */
    }

    not tested


    hth
    --
    P'tit Marcel
    P'tit Marcel Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139