Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3

Thread: Split text

  1. #1
    New to the CF scene
    Join Date
    May 2014
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Split text

    HI. Can anyone tell me how can I split text Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam mollis urna nisl, ut euismod purus adipiscing vitae. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent ultricies risus non arcu bibendum tempor. Aliquam eleifend nibh a nunc commodo congue. Donec faucibus blandit augue eu molestie. Praesent suscipit dapibus lectus, vitae pulvinar nisi suscipit id. Morbi id condimentum dolor. In molestie enim eget ante sagittis rutrum. Vivamus malesuada tortor nec orci aliquam, a imperdiet nisi ullamcorper. Integer rutrum nibh vitae turpis rutrum, at aliquet nibh blandit. Donec venenatis nisl id pulvinar venenatis. Vivamus in metus a sem accumsan dictum. to see how much words is with 2 letters, 3 letters, 4 letters,,,,etc
    For example:
    Number of word 2 letter are ...
    Number of word 3 letter are ...
    Number of word 3 letter are ...

  • #2
    Regular Coder low tech's Avatar
    Join Date
    Dec 2009
    Posts
    887
    Thanks
    174
    Thanked 101 Times in 101 Posts
    Maybe you can start by making an effort.

    LT
    "The greatest revenge is to accomplish what others say you cannot do."
    ~ Unknown

    I used to be indecisive, but now I'm not so sure.

  • #3
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    That's a little on the curt way of answering, but the sentiment is correct. You should try to perform this task as you will learn quite a bit.
    There are several ways to do this. You can start by using something like explode or str_word_count in order to get base arrays of words. Then you would iterate each item and count the chars, and store within an array by adding to the index where the index represents the number of chars in a word.
    Another approach is to simply iterate it character by character. Start a counter, and when it hits a space the word is complete. You then take the last count, and increment an array position by 1, and reset the counter. Start again with the next word, and so on.
    No matter the case, I do suggest using an array (or a custom collection of your choosing) for the output result as it'll really simplify the tracking.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)


  •  

    Posting Permissions

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