Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-04-2010, 01:54 AM   PM User | #1
mladja04
New to the CF scene

 
Join Date: Dec 2010
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
mladja04 is an unknown quantity at this point
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
mladja04 is offline   Reply With Quote
Old 12-04-2010, 02:03 AM   PM User | #2
mlseim
Master Coder

 
mlseim's Avatar
 
Join Date: Jun 2003
Location: Cottage Grove, Minnesota
Posts: 9,042
Thanks: 8
Thanked 1,029 Times in 1,020 Posts
mlseim has a spectacular aura aboutmlseim has a spectacular aura aboutmlseim has a spectacular aura about
Just curious what this is supposed to be for. very odd.
mlseim is offline   Reply With Quote
Old 12-04-2010, 11:05 AM   PM User | #3
Lamped
Super Moderator


 
Join Date: Feb 2009
Location: England
Posts: 539
Thanks: 8
Thanked 63 Times in 54 Posts
Lamped will become famous soon enough
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
Lamped is offline   Reply With Quote
Reply

Bookmarks

Tags
convert text, file, php

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:35 PM.


Advertisement
Log in to turn off these ads.