Paragraph Settings Using PHP, [ strings help needed ]

Discussion in 'PHP' started by strgraphics, Aug 18, 2010.

  1. #1
    Dear friends,

    My sir, gave me this following lines....



    " Your beloved will bring happiness and success to you,,,, your friends will support you in tough situations of life. Time to spend money on your homely accommodations..... Avoid being volunteer to overspend otherwise you will loose a lot "


    Hear are the following mistakes..

    > In the above lines, if you see you,,,,, hear we have to get a single comma not 4 commas

    > And accommodations....., hear we have to get single fulstop, not .....,

    > And at the end of the para if there is no fulstop.., we must get one fulstop ( . ),



    Once we run the program we have to get good paragraph with out anny errors...!!
    please help me or any ideas please.
     
    strgraphics, Aug 18, 2010 IP
  2. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #2
    
    $text = trim($text);
    $text = preg_replace('~([\.,])\1+~', '$1', $text);
    if (substr($text, -1) !== '.')
        $text .= '.';
    
    PHP:
    ... untested, but should work.

    Although, using 3 periods in a row is not incorrect grammar. Removing them might ruin the context of the sentence. And what if the last sentence ends with an exclamation mark?
     
    nico_swd, Aug 19, 2010 IP
  3. MyVodaFone

    MyVodaFone Well-Known Member

    Messages:
    1,048
    Likes Received:
    42
    Best Answers:
    10
    Trophy Points:
    195
    #3
    Looks like some kind of astrology script that throws out random lines, as @nico_swd's has said, removing them could make the sentence even more cryptic :) I don't know if that's a good or bad idea :confused: Myself I would start to edit the sentences, it might be a long and boring task, so maybe 50-100 a day, you will finish editing in a few days, problem solved.
     
    MyVodaFone, Aug 19, 2010 IP
  4. strgraphics

    strgraphics Active Member

    Messages:
    710
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    53
    #4
    Thanks a lot friend..,

    will try for sure, would be great ful to your help.

     
    strgraphics, Aug 19, 2010 IP