如何从数组php获取值



我的print_r($_GET);

输出是

    Array(
    [prevurl() ] => Array(
        [taxirate] => 3500[Source] => Land[T] => Yes[TId] => 10[dtaxirate] => 4500[TD] => Yes[TDId] => 14[modeset] => minivan[minivanrate] => 400[Minivan] => Yes[MinivanId] => 6[FirstSearch] => FirstSearch[returnTrip] => yes[return -one] => No[Trip] => OneWay[TravelFrom] => Destination[TravelTo] => Pak[TravelDay] => 2015 - 08 - 16[TotalCount] => 1[Mode] => [Both] => [BothReturn] => 2015 - 08 - 17[Adults] => 1[Childs] => [Kids] => [Babies] =>
    )
)

我试着

echo $_GET['prevurl']['taxirate'];但不工作

如何获取taxirate的值

<input type="hidden" value="Array
(
    [taxirate] => 3500
    [Source] => Land
    [T] => Yes
    [TId] => 10
    [dtaxirate] => 4500
    [TD] => Yes
    [TDId] => 14
    [modeset] => minivan
    [minivanrate] => 400
    [Minivan] => Yes
    [MinivanId] => 6
    [FirstSearch] => FirstSearch
    [returnTrip] => yes
    [return-one] => No
    [Trip] => OneWay
    [TravelFrom] => Hat Yai Airport
    [TravelTo] => Pak Bara
    [TravelDay] => 2015-08-16
    [TotalCount] => 1
    [Mode] => 
    [Both] => 
    [BothReturn] => 2015-08-17
    [Adults] => 1
    [Childs] => 
    [Kids] => 
    [Babies] => 
)
" name="prevurl">

更新:

注释:

这是我的input在前一页

<input type="hidden" value="Array
(
    [taxirate] => 3500
    [Source] => Land
    [T] => Yes
    [TId] => 10
    [dtaxirate] => 4500
    [TD] => Yes
    [TDId] => 14
    [modeset] => minivan
    [minivanrate] => 400
    [Minivan] => Yes
    [MinivanId] => 6
    [FirstSearch] => FirstSearch
    [returnTrip] => yes
    [return-one] => No
    [Trip] => OneWay
    [TravelFrom] => Hat Yai Airport
    [TravelTo] => Pak Bara
    [TravelDay] => 2015-08-16
    [TotalCount] => 1
    [Mode] => 
    [Both] => 
    [BothReturn] => 2015-08-17
    [Adults] => 1
    [Childs] => 
    [Kids] => 
    [Babies] => 
)
" name="prevurl()">

实际上输入是一个数组

假设数组值存储在变量中,我会尝试:

<?php
foreach ($array_data as $key=>$value)
{
    if($key == "prevurl")
    {
        foreach ($value as $key1=>$value1)
        {
            switch($key1)
            {
                case "taxirate":
                    $taxirate = $value1;
                break;
            }
        }
    }
}
?>

但是我同意Rasclatt的观点。这个数组看起来很奇怪。

编辑:你原来的问题看起来像一个多维数组,但你的编辑看起来不是多维的。我的答案来自你原来的代码

只需将隐藏的输入字段名称更改为name="prevurl"。得到taxirate的值为:

$_GET['prevurl']['taxirate'];

相关内容

  • 没有找到相关文章

最新更新