Page 1 of 1

Echo Form Results Results

Posted: Thu Apr 14, 2011 8:39 am
by clewis4343
Hello I apologize if I have not posted this in the right section, first day on here and certainly will not be the last.

I ask that someone help me not become bald... errr.. rather help me so I stop pulling my hair out.

Take this site for example.

http://www.tizag.com/phpT/examples/formexample.php

I understand the entire concept of this form in its primitive state. However, the part that is stumping me is how on earth can I make it seem grammitcally correct. ie. When the results echoed say you like Steak Pizza Chicken, how can I make it put comma's and the word and in the sentence. So if someone only says they like steak and pizza it will echo "you like steak and pizza." Or if they select all three for example, echo back saying "you like steak, pizza, and chicken."

Any help would be much appreciated.

Re: Echo Form Results Results

Posted: Thu Apr 14, 2011 12:30 pm
by social_experiment
It would depend on the amount of 'favourites' there is. You would code to accomodate 3 'values'. 1, 2 and more than two.

Code: Select all

<?php
 // more than two
 $array = array(
$_POST['valueOne'], $_POST['valueTwo'], $_POST['valueThree'];
);

 $results = implode(', ', $array);

 echo 'You like ' . $results;
?>
Hth