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.
Echo Form Results Results
Moderator: General Moderators
- social_experiment
- DevNet Master
- Posts: 2793
- Joined: Sun Feb 15, 2009 11:08 am
- Location: .za
Re: Echo Form Results Results
It would depend on the amount of 'favourites' there is. You would code to accomodate 3 'values'. 1, 2 and more than two.
Hth
Code: Select all
<?php
// more than two
$array = array(
$_POST['valueOne'], $_POST['valueTwo'], $_POST['valueThree'];
);
$results = implode(', ', $array);
echo 'You like ' . $results;
?>“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering