Home  >  Article  >  Backend Development  >  php post遍历有关问题

php post遍历有关问题

WBOY
WBOYOriginal
2016-06-13 11:15:311931browse

php post遍历问题

print_r($_REQUEST);

取到的值是
Array<br />(<br />    [c] => pay2<br />    [cart] => 1<br />    [itemid] => Array<br />        (<br />            [0] => 103<br />            [1] => 104<br />            [2] => 105<br />            [3] => 106<br />        )<br /><br />    [PHPSESSID] => rdkrfasknosmg58o1r1d9i6pf5<br />)


<br /><br />foreach ($_REQUEST as $key => $value) <br />{<br />    echo "Key: $key; Value: $value<br />\n";<br />}<br />
遍历不能遍历出itemid ,如何才能遍历成1,2,3这样


------解决方案--------------------
foreach ($_REQUEST as $key => $value) 
{
    if(is_array($value)) $value = join(',', $value);
    echo "Key: $key; Value: $value
\n";
}
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn