Re: Break Word

From: Tim Van Wassenhove (euki_at_pi.be)
Date: 06/14/04


Date: 14 Jun 2004 18:18:28 GMT

In article <a5e41e0e.0406140652.4a0bb43@posting.google.com>, knoak wrote:
> How can i detect after submitting if any word
> from the field is longer then e.g. 15 chars.
> If so, break it at the 14th char, add a dash,
> an continue at the next line...

It depends on what you depend what a word is.
Assuming that every group of characters that is separated by space is
defined as a word.

You could easily lookup with strpos where the spaces occur in a string.
The distance between 2 such positions would be the length of the word.

Or you could use the split function to get all the "words" and use
strlen to determine how long they are.

After this you can use substr to grab parts out of such a word.

More on the functions mentionned above can be found at
http://www.php.net/manual -> string functions.

-- 
Tim Van Wassenhove <http://home.mysth.be/~timvw>


Relevant Pages

  • Re: Break Word
    ... knoak wrote: ... > How can i detect after submitting if any word ... > If so, break it at the 14th char, add a dash, ...
    (comp.lang.php)
  • Re: trim function dumping core
    ... I am not sure what should be the behaviour of l/r/all trim against NULL ... ptr, on my sys is Seg Fault. ... char* trim ... It is up to the caller to ensure against NULL pointers passed to string functions, ...
    (comp.lang.c)
  • Re: String copy with pointers not working as expected
    ... be able to get working without the use of string functions such as ... int main ... char *p; ... the 'q' pointer... ...
    (comp.lang.c)
  • Re: Comment on trim string function please
    ... Why not return a char *, like most other string functions? ... char *TrimCString(char *str) ... Maybe use memmoveinstead of the loop. ...
    (comp.lang.c)
  • Re: Another Understanding Pointers Question
    ... > that I was using pointers in the correct way. ... but I just wanted to test writing my own functions. ... As far as I think your string functions ... char *left ...
    (comp.lang.c)