473,395 Members | 1,526 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,395 software developers and data experts.

breaking up strings

Hello
I have a string of varying length, lets call it $mystring.
I wish to break it up and put it in the following form

echo"<span
class='myclass'>".1st_30chars_$mystring_to_nearest _word."<br>".2nd_30chars_$
mystring_to_nearest_word."<br>".....etc....last_lo t_of_chars_of_$mystring."<
/span>";

does anyone know how to do this
Ian
Jul 29 '06 #1
3 1103
<comp.lang.php>
<Ian Davies>
<Sat, 29 Jul 2006 23:42:48 GMT>
<Yn*******************@newsfe6-win.ntli.net>
I have a string of varying length, lets call it $mystring.
I wish to break it up and put it in the following form

echo"<span
class='myclass'>".1st_30chars_$mystring_to_nearest _word."<br>".2nd_30chars_$
mystring_to_nearest_word."<br>".....etc....last_lo t_of_chars_of_$mystring."<
/span>";
http://uk2.php.net/manual/en/function.wordwrap.php
--
Encrypted email address
www.emailuser.co.uk/?name=KRUSTOV
Make a shorter url
www.vhit.co.uk
Jul 29 '06 #2

Ian Davies wrote:
Hello
I have a string of varying length, lets call it $mystring.
I wish to break it up and put it in the following form

echo"<span
class='myclass'>".1st_30chars_$mystring_to_nearest _word."<br>".2nd_30chars_$
mystring_to_nearest_word."<br>".....etc....last_lo t_of_chars_of_$mystring."<
/span>";

does anyone know how to do this
Ian
Someone else has already posted referencing the wordwrap function; if
you wish to do it yourself - ie: more customization than wordwrap can
give you - use the following psuedo-code that takes advantage of strtok
(note: I haven't validated this hence it's psuedo-code not 'true' code
):

$x = 'sentance of some length';
$y = strtok( $x, ' ' );
$curpos = 0;
while( !( $y == null ) )
{
echo $y;
if( strlen($y) + $curpos 30 )
{
echo '<br>';
$curline = 0;
}
$y = strtok( $x );
}

- Craig Taylor
http://www.ctalkobt.net

Jul 30 '06 #3
Thanks all thats exactly what I was looking for.
wordwrap was adequate for my needs
Ian

"Ian Davies" <ia********@virgin.netwrote in message
news:Yn*******************@newsfe6-win.ntli.net...
Hello
I have a string of varying length, lets call it $mystring.
I wish to break it up and put it in the following form

echo"<span
class='myclass'>".1st_30chars_$mystring_to_nearest _word."<br>".2nd_30chars_$
>
mystring_to_nearest_word."<br>".....etc....last_lo t_of_chars_of_$mystring."<
/span>";

does anyone know how to do this
Ian


Jul 30 '06 #4

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

Similar topics

0
by: MarionEll | last post by:
--------------------------------------------------------- ************* Call for Participation ************** ************ Late Breaking News ************* *********** Extreme...
0
by: Amy | last post by:
I am looking for an rss feed that contains really important breaking news like "A large Tsunami just hit Asia" or "Terrorists attack the World Trade Center", but is empty if there really isn't...
27
by: The Bicycling Guitarist | last post by:
Hi. I found the following when trying to learn if there is such a thing as a non-breaking hyphen. Apparently Unicode has a ‑ but that is not well-supported, especially in older browsers. Somebody...
22
by: stevenkobes | last post by:
If a word has a hyphen in it, IE will permit a line break at the hyphen, but Firefox/Mozilla won't. Apparently the Firefox behavior is standards-compliant, but it is not what I want. Is there a...
4
by: John Wood | last post by:
I saw that Microsoft have released a list of breaking changes in .Net here: http://msdn.microsoft.com/netframework/programming/breakingchanges/runtime/default.aspx While this is useful, it seems...
49
by: elmar | last post by:
Hi Clers, If I look at my ~200000 lines of C code programmed over the past 15 years, there is one annoying thing in this smart language, which somehow reduces the 'beauty' of the source code...
2
by: Ben | last post by:
I have this data I want to send over the network to the server. It is working fine except I don't know how to break up the buffer on the receiving side. On the client I am sending...
4
by: Rubin | last post by:
1) I want to show a breaking hyphen in Mozilla 1.5.0.4 How do I do that? "Unicode standard annex #14", <http://www.unicode.org/reports/tr14/>, defines 4 breaking hyphens. <quote> Breaking...
5
by: Michael Yanowitz | last post by:
Hello: I have been searching for an easy solution, and hopefully one has already been written, so I don't want to reinvent the wheel: Suppose I have a string of expressions such as: "((($IP =...
2
by: gitimaya | last post by:
hi, can anyone please help me in breaking up a string in array of strings. The delimeter is a character declared as '\001'. lets say i have a string as char d='\001' xxx'd'yyy'd'aaa i...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.