Log in

View Full Version : PHP Question


Raven_Writer
22-05-2004, 16:05
While trying to get back in the swing of things (again) w/ PHP, I decided to make a lil' poetry script. Basically, you type in some info, and then it sends you to a page asking if the information is correct, then it saves it as a file.

My problem is in the checking to see if the poem is correct. I can't show the poem. Currently, what I'm doing is:


$poem = $_POST['poem'];

<?if($poem == ""){
echo("no poem");
}else{
$show = explode(" ", $poem);
echo("$show");
}?>


The thing that is displayed (when there's a poem), is "Array" (w/o quotes). I have looked at the PHP document on this, and couldn't find really anything. Does anyone know how to fix this? (If I don't use explode, and just show the poem, it displays the newline characters as double-spaces).

Guest
22-05-2004, 18:19
This should work.

You can't "echo" an array. nl2br converts all new lines into HTML <BR> tags.

Correct code:

$poem = $_POST['poem'];

<?if($poem == ""){
echo("no poem");
}else{
$show = nl2br($poem);
echo("$show");
}?>

Raven_Writer
22-05-2004, 18:42
Thank you. Apperantly, I had to refresh more than once. It works now....thanks again much.