• Howdy! Welcome to our community of more than 130.000 members devoted to web hosting. This is a great place to get special offers from web hosts and post your own requests or ads. To start posting sign up here. Cheers! /Peo, FreeWebSpace.net
managed wordpress hosting

this is killing me: textarea to list in php

keith

anti-liberal
NLC
ok, let's get right down to it:

i have a text area [name="info"], and would like to get ech line to hold it's own piece of information... so the textarea input reads out like this:
Code:
line1
line2
line3
here's the code to decipher the info:
PHP:
<?
$info= trim("$info");
$info= explode("\n", $info);
$info= implode("|", $info);
$info= trim("$info");
?>
it then writes it to a file... i'd like it to read out like this:
Code:
line1|line2|line3
but it writes it like this:
Code:
line1
|line2
|line3
what the hell am i doing wrong??
 
give this a try (it's because you haven't removed the carriage return \r)...

PHP:
<?php
if (!isset($info)) {
    echo '<form name="form1">
    <textarea name="info"></textarea>
    <input type="submit">
    </form>';
} else {
    $info2 = ereg_replace ("\r\n", "|", $info);
    echo $info2;
}
?>
 
give the man an award... thanks a ton! didn't even think about the carriage return. kudos.
 
Back
Top