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
  1. #1
    New to the CF scene
    Join Date
    Dec 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Create PHP code which convert words and save into file - need help

    Hello,

    I am novice in PHP, I read book and try to write some PHP code, but I don't have success in that my attempt.
    Do someone can to help me? I think that this what I work isn't hard, but I don't know to do.


    I need to create in PHP some code which will:

    1. In text field I enter some words in 2-3 rows, example
    word11 word12 word13
    word21 word22 word23
    word31 word32 word33
    and click to button Convert,

    2. After click on that button php script will take that words and convert into this mode:
    word11-word12-word13(TAB here without space)word11 word12 word23
    word21-word22-word23(TAB here without space)word21 word22 word23
    word31-word32-word33(TAB here without space)word31 word32 word33

    (spaces between words will convert into - and between first and second mode with TAB)

    3. On that way converted text to be saved into new file which will be with name of first line "word11 word12 word13".



    I know procedure to make this, but I don't know syntax very well

    Can someone write me code or part of code, to give me idea how I to make this?


    Thank you very much, Mladen

  • #2
    Master Coder mlseim's Avatar
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,371
    Thanks
    8
    Thanked 1,075 Times in 1,066 Posts
    Just curious what this is supposed to be for. very odd.

  • #3
    Super Moderator
    Join Date
    Feb 2009
    Location
    England
    Posts
    539
    Thanks
    8
    Thanked 63 Times in 54 Posts
    PHP Code:
    function doWhatPosterWanted($textarea) {
        
    $lines explode("\n"$textarea);
        foreach(
    $lines as $key => $value) {
            
    $split explode(' '$value);
            
    $lines[$key] = implode('-'$split)."\t".implode(' '$split);
        }
        return 
    implode("\n"$lines);
    }

    echo 
    doWhatPosterWanted($_POST['mytextarea']); 
    Something like that.
    lamped.co.uk :: Design, Development & Hosting
    marcgray.co.uk :: Technical blog


  •  

    Tags for this Thread

    Posting Permissions

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