Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/231.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从php的多级数组中删除指定的索引_Php - Fatal编程技术网

从php的多级数组中删除指定的索引

从php的多级数组中删除指定的索引,php,Php,我使用多级数组,数组中的数组。我有一个索引“|”,我只是用它来克隆表单元素,但当我保存表单时,它就成为我的php数组的一部分。请让我知道如何用短代码删除它。我还使用了PHP函数“array\u walk”和“array\u walk\u recursive”,但没有成功,下面是我的数组的显示 Array ( [banner_heading] => Get Started Here! [banner_text] => <pre id="line1">aaaa</pre

我使用多级数组,数组中的数组。我有一个索引“|”,我只是用它来克隆表单元素,但当我保存表单时,它就成为我的php数组的一部分。请让我知道如何用短代码删除它。我还使用了PHP函数“array\u walk”和“array\u walk\u recursive”,但没有成功,下面是我的数组的显示

Array
(
[banner_heading] => Get Started Here!
[banner_text] => <pre id="line1">aaaa</pre>
[banner_button] => [button_blue link="#"]Buy Now[/button_blue]
[banner_media] => image
[upload_banner] => /wp-content/uploads/2013/07/videoImg.jpg
[youtube_video] => Oo3f1MaYyD8
[vimeo_video] => 24456787
[intro_heading] => Anyone Can Accept Credit Cards with Square
[intro_text] => 
[feature_content] => Array
    (
        [1] => Array
            (
                [title] => Free Secure Card Reader
                [description] => Sign up and we’ll mail you a free card reader. The reader fits right in your pocket and securely encrypts every swipe.
                [link] => #
                [icon] => /wp-content/uploads/2013/07/cardIcon.jpg
            )

        [2] => Array
            (
                [title] => Easy Setup
                [description] => Download the free Square Register app and link your bank account. No setup fees or long-term contracts. You’ll be accepting payments on your smartphone or iPad in minutes.
                [link] => #
                [icon] => /wp-content/uploads/2013/07/easyIcon.jpg
            )

        [3] => Array
            (
                [title] => Simple Pricing
                [description] => Pay just 2.75% per swipe for all major credit cards or a flat monthly $275. No other fees—so you know exactly what you pay. Square’s pricing fits businesses of all sizes.
                [link] => #
                [icon] => /wp-content/uploads/2013/07/pricingIcon.jpg
            )

        [5] => Array
            (
                [title] => 
                [description] => 
                [link] => 
                [icon] => 
            )

        [|] => Array
            (
                [title] => 
                [description] => 
                [link] => 
                [icon] => 
            )

    )
)
数组
(
[横幅标题]=>从这里开始!
[banner_text]=>aaaa
[banner_button]=>[button_blue link=“#”]立即购买[/button_blue]
[banner_media]=>图像
[upload_banner]=>/wp content/uploads/2013/07/videoImg.jpg
[youtube_视频]=>Oo3f1MaYyD8
[vimeo_视频]=>24456787
[intro_heading]=>任何人都可以使用Square接受信用卡
[介绍文字]=>
[功能内容]=>阵列
(
[1] =>阵列
(
[标题]=>免费安全读卡器
[说明]=>注册后,我们会寄给您一个免费的读卡器。该读卡器正好放在您的口袋中,并安全地加密每次刷卡。
[链接]=>#
[图标]=>/wp content/uploads/2013/07/cardIcon.jpg
)
[2] =>阵列
(
[标题]=>轻松设置
[说明]=>下载free Square Register应用程序并链接您的银行帐户。无需安装费或长期合同。您将在几分钟内接受智能手机或iPad上的付款。
[链接]=>#
[图标]=>/wp content/uploads/2013/07/easyIcon.jpg
)
[3] =>阵列
(
[标题]=>简单定价
[说明]=>对于所有主要信用卡,每次刷卡只需支付2.75%的费用,或者每月支付275美元。无需支付其他费用,因此您可以准确了解自己的支付金额。Square的定价适合各种规模的企业。
[链接]=>#
[图标]=>/wp content/uploads/2013/07/pricingIcon.jpg
)
[5] =>阵列
(
[标题]=>
[说明]=>
[链接]=>
[图标]=>
)
[|]=>数组
(
[标题]=>
[说明]=>
[链接]=>
[图标]=>
)
)
)
您可以使用:

您可以使用:


以下函数可用于递归获取数组中键为
|
的节点的路径。它返回以字符串分隔的冒号连接的路径节点数组,例如
$out=array('key1:key2:|','key3:|')

一旦获得该值,您可以按如下方式清理阵列:

$out = $this->get_path($arr);
if ( ! empty($out)){
    foreach ($out as $str){
        $path = explode(':', $str);
        array_pop($path);
        $nester = &$arr;
        foreach ($path as $node){
            $nester = &$nester[$node];
        }
        unset($nester['|']);
    }
}
print_r($arr);

以下函数可用于递归获取数组中键为
|
的节点的路径。它返回以字符串分隔的冒号连接的路径节点数组,例如
$out=array('key1:key2:|','key3:|')

一旦获得该值,您可以按如下方式清理阵列:

$out = $this->get_path($arr);
if ( ! empty($out)){
    foreach ($out as $str){
        $path = explode(':', $str);
        array_pop($path);
        $nester = &$arr;
        foreach ($path as $node){
            $nester = &$nester[$node];
        }
        unset($nester['|']);
    }
}
print_r($arr);

我不能这样做,因为我必须做一些动态代码,我写了一个函数来清理我的所有数组,但什么也不做。函数CL($Arr){if(is_array($Arr)){unset($Arr[''|']);foreach($Arr as$input_ind=>$input_val){if(is_array($input_val)){unset($input| val['.}}return$Arr;}我不能这样做,因为我必须做一些动态代码,我写了一个函数来清理我的所有数组,但什么也不做。函数_CL($Arr){if(is_array($Arr)){unset($Arr[''.''''.');foreach($Arr as$input_ind=>input_val){if(is_array($input_val)){unset($input_val['.})}}返回$Arr;}
$out = $this->get_path($arr);
if ( ! empty($out)){
    foreach ($out as $str){
        $path = explode(':', $str);
        array_pop($path);
        $nester = &$arr;
        foreach ($path as $node){
            $nester = &$nester[$node];
        }
        unset($nester['|']);
    }
}
print_r($arr);