Split sprintf() in foreach loop

A simple question i can't figure out. I'm having this simple sendmail script in php. But i need the printet array (that prints the body of the email) to be splittet up.

What is the simplest solution to make the outcome from the foreach loop be:
1. In the first 4 posts in the array, only the value and not the key from the post is printet
2. The rest of the array is printet, both keys and values.
I'm currently using this:

 foreach($fields as $a => $b){ $body .= sprintf("%20s: %sn",$b,$_REQUEST[$a]); }

Can't seem to get my head around it. Any help is very welcome! Troels


就像是?

$i = 0;
foreach($fields as $a => $b) {
 $i++;
 if ($i>3) $body .= sprintf("%20s: %sn",$b,$_REQUEST[$a]);
}
链接地址: http://www.djcxy.com/p/53016.html

上一篇: 在foreach循环中替换数组值

下一篇: 在foreach循环中拆分sprintf()