Copyright © 2005-2008 Andrea Tincani

AndreaPHP | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (Problem with a class.. again!!)Next Topic (Class v.s. Procedural) New Topic New Poll Post Reply
AndreaPHP Forum : PHP General : Seperating each line of a textbox
Poster Message
neutrall
Level: Scholar


Registered: 28-03-2004
Posts: 43

icon Seperating each line of a textbox

     I'm currently building the administration menu of a game I'm building.
     When you deafeat a creature, a custum message will appear, the same if you loose.
     Now I'm building the Creature management page, and in the entry form and edit form of a creature, I would like to have a text box where each line (After a CrLr command) would be a different record in a message table.

Daniel B.

____________________________
A Stick give a wise man something to think about... and a fool, something to put in is mouth.

04-05-2005 at 02:51 AM
View Profile Send Email to User Show All Posts Visit Homepage ICQ | Quote Reply
admin
Level: Administrator


Registered: 04-04-2002
Posts: 35

icon Re: Seperating each line of a textbox

you can use the split function to obtain an array of elements from a string


$line = split("/\n", $input_several_lines_long);



then you can save each element of the $line array into your table

____________________________
AndreaVB

04-05-2005 at 09:27 AM
View Profile Send Email to User Show All Posts Visit Homepage | Quote Reply
neutrall
Level: Scholar


Registered: 28-03-2004
Posts: 43

icon Re: Seperating each line of a textbox

I tried this, but it doesn't seam to work ...  Here my code :


<?php
$wonsentence 
$_POST['wonsentence'];
$lostsentence $_POST['lostsentence'];

$wonsentence explode("/\n"$wonsentence);
$lostsentence explode("/\n"$lostsentence);

foreach (
$wonsentence as $sentence) {
    
$creature->New_Win_Msg($sentence);
}
foreach (
$lostsentence as $sentence) {
  
$creature->New_Lost_Msg($sentence);
}
?>



I've look into my database where the entry is suppose to go, and no split (or explode) had occur. My three test line where not split into three in the array.

Any idea?

[Edited by neutrall on 12-05-2005 at 10:37 AM GMT]

____________________________
A Stick give a wise man something to think about... and a fool, something to put in is mouth.

05-05-2005 at 03:57 AM
View Profile Send Email to User Show All Posts Visit Homepage ICQ | Quote Reply
admin
Level: Administrator


Registered: 04-04-2002
Posts: 35

icon Re: Seperating each line of a textbox

try removing the escape character, your code becomes like this:


<?$wonsentence explode("\n"$wonsentence);?>



[Edited by admin on 12-05-2005 at 12:02 PM GMT]

____________________________
AndreaVB

05-05-2005 at 05:42 AM
View Profile Send Email to User Show All Posts Visit Homepage | Quote Reply
neutrall
Level: Scholar


Registered: 28-03-2004
Posts: 43

icon Re: Seperating each line of a textbox

Thank you... I'ts now working....



____________________________
A Stick give a wise man something to think about... and a fool, something to put in is mouth.

05-05-2005 at 04:36 PM
View Profile Send Email to User Show All Posts Visit Homepage ICQ | Quote Reply
AndreaPHP Forum : PHP General : Seperating each line of a textbox
Previous Topic (Problem with a class.. again!!)Next Topic (Class v.s. Procedural) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: AndreaVB

Copyright © 2005-2008 Andrea Tincani

Powered by: tForum tForum Edition b0.92p1
Originally created by Toan Huynh (Copyright © 2000)
Enhanced by the tForumHacks team.