473,387 Members | 1,493 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Split text into two columns

Tim
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
Jul 16 '05 #1
2 13232
"Tim" <tj******@hotmail.com> wrote
in message news:<lw********************@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
Jul 16 '05 #2
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
Jul 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: SL_McManus | last post by:
Hi All; I am fairly new to Perl. I have a file with close to 3000 lines that I would like to split out in a certain way. I would like to put the record type starting in column 1 for 2 spaces,...
5
by: chrisgeary | last post by:
i have a function (below) which reads the last n lines from a text file. rather than read the whole line and output it as is, i want to be able to read the line and split the tab delimited text...
7
by: byoxemeek | last post by:
I have an array created from an undelimited text file I receive with a format like: 60190012003010203040506070809101112 60190012004010203040506070809101112 6019001200501020304...
3
by: Jan Hanssen | last post by:
Hi! I have a list of data in a textfile which is tab delimited. Each line is seperated by a VbCrLf. I want to collect this data in a multidimensional string array. I do not wish to use a...
2
by: dineshbajaj | last post by:
Hi Everybody, I need to split an image file(*.jpeg) programmatically to nine or more equal parts. Since, the code is meant to run on Windows Pocket PC 2002, I can only use methods supported...
3
by: ashok | last post by:
Hi, I need a function that will divide text from mysql in 2 parts, so that I can display first half in one column and second half in second column. I can't find what function will do this job....
2
by: Dscar | last post by:
Hi, I am a beginner in ACCESS, I've imported data into access, and then realized that I need to split the information in one of my columns into 2 columns. the information looks like this:...
5
by: chinni0719 | last post by:
Hi I need to split the string which looks like n.col1 , b.col1 , n.col2 , b.col2, n.col3 , b.col3 , b.col4 , n.col4 , b.col5,n.col5 n.col1,n.col2 are columns these are present in...
13
by: kashif73 | last post by:
I have a texfile with hundreds of records. Each record in a line has 1250 values & values are seperated by a semi colon. IS there a way in VB.NET that i can split each line for example first 1000...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.