0
$myarr = array(1) {
    [0]=> array(5) { 
        [0]=> array(4) {
            ["label"]=> string(50) "Главная" ["link"]=> string(25) "https://my.site/" ["title"]=> string(50) "Главная" ["type"]=> string(9) "blog_home"
        } 

        [1]=> array(4) {
            ["label"]=> string(27) "Блог" ["link"]=> string(41) "https://my.site/" ["title"]=> string(27) "Блог" ["type"]=> string(7) "kb_home"
        } 

        [2]=> array(4) {
            ["label"]=> string(30) "Авто" ["link"]=> string(49) "https://my.site/" ["title"]=> string(76) "Просмотреть все записи в Авто" ["type"]=> string(6) "kb_tax"
        } 

        [3]=> array(4) {
            ["label"]=> string(39) "Природа" ["link"]=> string(51) "https://my.site/" ["title"]=> string(85) "Просмотреть все записи в Природа" ["type"]=> string(6) "kb_tax"
        } 

        [4]=> array(4) {
            ["label"]=> string(60) "Новости" ["link"]=> string(58) "https://my.site/" ["title"]=> string(60) "Новости" ["type"]=> string(15) "kb_current_page"
        }
    }
}

Нужно удалить

[1]=> array(4) {
    ["label"]=> string(27) "Блог" ["link"]=> string(41) "https://my.site/" ["title"]=> string(27) "Блог" ["type"]=> string(7) "kb_home"
} 

Пробовал так

<?php array_slice($myarr, 1);?>

2 ответа 2

0
unset($myarr[0][1]);

Функция unset удалит элемент.

1
  • @eanmos да он удаляет, но тогда последовательность [0] [2] [3] [4], а мне нужно чтобы следующая строчка была c ключем [1]=> array(4) { ["label"]=> string(30) "Авто" ["link"]=> string(49) "my.site" ["title"]=> string(76) "Просмотреть все записи в Авто" ["type"]=> string(6) "kb_tax" }
    – Fibonacci
    22 июл 2019 в 22:41
0

Удалить элемент, после - переиндесировать значения.

unset($myarr[0][1]);
$myarr[0] = array_values($myarr[0]);

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.