Re: Problem with a my function and a simple mail
| From: | Matt McClanahan | Date: | Wed, 23 Aug 2000 21:25:50 +0000 |
| Subject: | Re: Problem with a my function and a simple mail | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-13238@lists.php.net to get a copy of this message | ||
On Thu, 24 Aug 2000, n e t b r a i n wrote:
> Hi,
>
> in order to print some values submitted by a client form in a simply email
> in text format, I've tried to write in php3 a simple function that doesn't
> seem to work right ...
>
> function list_my_values($var_array) {
> while(list($key,$value)=each($var_array)) {
> echo("".stripslashes(strip_tags(escapeshellcmd($key))).":
> ".stripslashes(strip_tags(escapeshellcmd($value)))."");
> }
> }
You want your function to return the text, not echo it.
So instead of using an echo, set a string and concatenate onto it in the
while loop, then return the string when the while loop finishes.
function list_my_values($var_array)
{
while( list($key,$val) = each($var_array) )
{
$output .= yaddayadda
}
return $output;
}
Matt