表单返回单词“Array”

时间:2013-12-13 19:07:16

标签: php arrays forms

我知道这很简单但不确定为什么我的php表单只返回“Array”这个词。这是表单的一部分,以及重新调整“数组”的“评论”页面的php。

form.php的

<div class="clubPhotos">
    <div class="club">
        <img src="clubs/img/praxispi.png" class="clubPhoto" />
        <span class="clubTitle">Praxis PI</span>
        <span class="clubSub">Low Launch 9.5</span>
        <input type="checkbox" id="clubCheckbox4" class="clubCheckbox" name="DriverType[Low Launch 9.5]" value="Praxis PI Low Launch 9.5" />
    </div>
    <div class="club">
        <img src="clubs/img/praxispi.png" class="clubPhoto" />
        <span class="clubTitle">Praxis PI</span>
        <span class="clubSub">Mid-Low Launch 12.5</span>
        <input type="checkbox" id="clubCheckbox1" class="clubCheckbox" name="DriverType[Mid-Low Launch 12.5]" value="Praxis PI Mid-Low Launch 12.5" />
    </div>
    <div class="club">
        <img src="clubs/img/praxispi.png" class="clubPhoto" />
        <span class="clubTitle">Praxis PI</span>
        <span class="clubSub">Mid-High Launch 15.5</span>
        <input type="checkbox" id="clubCheckbox2" class="clubCheckbox" name="DriverType[Mid-High Launch 15.5]" value="Praxis PI Mid-High Launch 15.5" />
    </div>
    <div class="club last">
        <img src="clubs/img/praxispi.png" class="clubPhoto" />
        <span class="clubTitle">Praxis PI</span>
        <span class="clubSub">High Launch 18.5</span>
        <input type="checkbox" id="clubSelect" class="clubCheckbox" name="DriverType[High Launch 18.5]" value="Praxis PI High Launch 18.5" />
    </div>
    <div class="clear"></div>
</div>

review.php

echo (!empty($_REQUEST['DriverType'])) ? "<div class='reviewItem'><span class='reviewTitle'>Driver:</span>{$_REQUEST['DriverType']}</div>" : "";

我尝试更改为DriverType[],但没有成功。

2 个答案:

答案 0 :(得分:5)

$_REQUEST['DriverType']是一个数组。因此,您需要的值可以在其中的数组中找到。您将需要遍历数组以从中获取值。

我怀疑你只想要一个项目,所以将这些项目更改为单选按钮可能是一个更好的方法:

<input type="radio" id="clubSelect" class="clubCheckbox" name="DriverType" value="Praxis PI High Launch 18.5" />

然后您的代码将按预期工作。

答案 1 :(得分:2)

尝试

echo $_REQUEST['DriverType'][0]

我怀疑你只对一个元素感兴趣。