470,815 Members | 1,364 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,815 developers. It's quick & easy.

How to split a string by number of chars ?

This has been done before but not sure how:

Say I have a string of 1000 chars. I want to split the string into two
variables (two array element variables would be OK) one has 200 chars
the other has 800 chars. How would I do this? Must be simple in PHP...
Jul 17 '05 #1
3 3107
On Sun, 07 Nov 2004 19:39:28 GMT, leegold2 <le*****@nospam.net> wrote:
This has been done before but not sure how:

Say I have a string of 1000 chars. I want to split the string into two
variables (two array element variables would be OK) one has 200 chars
the other has 800 chars. How would I do this? Must be simple in PHP...


substr

--
Andy Hassall / <an**@andyh.co.uk> / <http://www.andyh.co.uk>
<http://www.andyhsoftware.co.uk/space> Space: disk usage analysis tool
Jul 17 '05 #2
Andy Hassall wrote:
On Sun, 07 Nov 2004 19:39:28 GMT, leegold2 <le*****@nospam.net> wrote:

This has been done before but not sure how:

Say I have a string of 1000 chars. I want to split the string into two
variables (two array element variables would be OK) one has 200 chars
the other has 800 chars. How would I do this? Must be simple in PHP...

substr

Like:
$d_content1 = substr($d_content,0,100);
$d_content2 = substr($d_content,100);

But, I need it to break the string on the nearest word. I jusr realized
that because I got:

$d_content1 == ....this is really gre
$d_content2 == at

I need it to do:

$d_content1 == ....this is really
$d_content2 == great

Thanks,
Lee G.
Jul 17 '05 #3
.oO(leegold2)
But, I need it to break the string on the nearest word.


http://www.php.net/wordwrap

Micha
Jul 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by William Stacey [MVP] | last post: by
7 posts views Thread by lgbjr | last post: by
11 posts views Thread by Brian | last post: by
232 posts views Thread by robert maas, see http://tinyurl.com/uh3t | last post: by
14 posts views Thread by tom t/LA | last post: by
3 posts views Thread by Ondrej Baudys | last post: by
reply views Thread by mihailmihai484 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.