0

我有这个数组:

$array = array(
    "foo" => "bar",
    "barw"    => "21",
    "bara"    => "22",
    "barq"    => "25",
    "multix" => array(
         "1" => array(
             "ar1" => "food",
             "ar2" => "dr",
             "ar3" => "ch",
             "ar4" => "ju"
         ),
        "2" => array(
             "ar1" => "food",
             "ar2" => "dr",
             "ar3" => "ch",
             "ar4" => "ju"
         ),
    "893" => "bar",
    "563" => "bar",
    "hd8" => "bar",
    "multiv" => array(
         "1" => array(
             "ar1" => "food",
             "ar2" => "dr",
             "ar3" => "ch",
             "ar4" => "ju"
         ),
         "2" => array(
             "ar1" => "food",
             "ar2" => "dr",
             "ar3" => "ch",
             "ar4" => "ju"
         ),
    "tw" => "bar",
    "qa" => "bar",
    "op" => "bar"
    )
    )
);

我正在阅读和写作这样的内容:

echo '<pre>';
print_r($array);
echo '</pre>';

echo "<br/>";
echo $array['multix']['1']['ar1'].'<br/>';
echo "<br/>";
echo $array['multix']['1']['ar2'].'<br/>';
echo "<br/>";
echo $array['multix']['1']['ar3'].'<br/>';
echo "<br/>";
echo $array['multix']['1']['ar4'].'<br/>';
$array['multix']['1']['ar4'] = "lego";

但是,我无法删除我选择的数组,例如:

unset($array['multiv']['1']);

echo '<pre>';
print_r($array);
echo '</pre>';

我应该怎么做才能使用它的键删除数组?

4

1 回答 1

3

multiv的数组在数组里面,multix所以你需要在multix名字前面加上

unset($array['multix']['multiv']['1']);

如果multiv应该是索引级别的一个,您可能会错误地设置您的数组。

于 2013-09-06T13:02:42.617 回答