...

View Full Version : Create PHP code which convert words and save into file - need help



mladja04
12-04-2010, 01:54 AM
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

mlseim
12-04-2010, 02:03 AM
Just curious what this is supposed to be for. very odd.

Lamped
12-04-2010, 11:05 AM
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.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum