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

php post遍历有关问题

WBOY
Release: 2016-06-13 11:15:31
Original
1951 people have browsed it

php post遍历问题

print_r($_REQUEST);
Copy after login

取到的值是
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 />)
Copy after login


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


------解决方案--------------------
foreach ($_REQUEST as $key => $value) 
{
    if(is_array($value)) $value = join(',', $value);
    echo "Key: $key; Value: $value
\n";
}
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template