Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/239.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,我试图从这个脚本中获取菜单,但当我这样尝试时,它会说输入非法偏移量 $menu_issems = array( [0] => array( [id] => "1", [url] => 'http://www.mixcms.dev', [parent_id] => "0", [name] => 'Accueil', [order] => "0" ),

我试图从这个脚本中获取菜单,但当我这样尝试时,它会说输入非法偏移量

$menu_issems = array(
    [0] => array(
        [id] => "1", 
        [url] => 'http://www.mixcms.dev', 
        [parent_id] => "0", 
        [name] => 'Accueil', 
        [order] => "0"
    ), 
    [1] => array(
        [id] => "32", 
        [url] => 'http://www.mixcms.dev/nos-formations.html', 
        [parent_id] =>"0", 
        [name] => 'Nos formations', 
        [order] => "10"
    ), 
    [2] => array(
        [id] => "33", 
        [url] => 'http://www.mixcms.dev/bac-professionnel-gestion-adnimistration.html', 
        [parent_id] => "32", 
        [name] => 'Bac professionnel : GESTION ADNIMISTRATION', 
        [order] => "20"
    ), 
    [3] => array(
        [id] => 34, 
        [url] => 'http://www.mixcms.dev/bac-professionnel-arcu.html', 
        [parent_id] => 32, 
        [name] => 'Bac professionnel : ARCU', 
        [order] => "30"
    ), 
    [4] => array(
        [id] => "35", 
        [url] => 'http://www.mixcms.dev/bac-professionnel-commerce.html', 
        [parent_id] => "32", 
        [name] => 'Bac professionnel : COMMERCE', 
        [order] => "40"
    ), 
    [5] => array(
        [id] => "36", 
        [url] => 'http://www.mixcms.dev/les-marques-partenaires.html', 
        [parent_id] => 32, 
        [name] => 'Bac professionnel : VENTE', 
        [order] => 50
    ), 
    [6] => array(
        [id] => "54", 
        [url] => 'http://www.mixcms.dev/bac-professionnel-option-comptabilite-et-finance-d-rsquo-entreprise.html', 
        [parent_id] => "32", 
        [name] => 'Bac professionnel : OPTION COMPTABILITÉ ET FINANCE D’ENTREPRISE', 
        [order] => "60"
    ), 
    [7] => array(
        [id] => "55", 
        [url] => 'http://www.mixcms.dev/bac-technologique-communication-et-gestion-des-ressources-humaines.html', 
        [parent_id] => "32", 
        [name] => 'Bac technologique : COMMUNICATION ET GESTION DES RESSOURCES HUMAINES', 
        [order] => "70"
    ), 
    [8] => array(
        [id] => "39", 
        [url] => 'http://www.mixcms.dev/presentation.html', 
        [parent_id] => 0, 
        [name] => 'Présentation', 
        [order] => 80
    ), 
    [9] => array(
        [id] => 40, 
        [url] => 'http://www.mixcms.dev/historique.html', 
        [parent_id] => "39", 
        [name] => 'Historique', 
        [order] => "90"
    ), 
    [10] => array(
        [id] => "41", 
        [url] => 'http://www.mixcms.dev/nos-atouts.html', 
        [parent_id] => "39", 
        [name] => 'Nos atouts', 
        [order] => "100"
    ), 
    [11] => array(
        [id] => "56", 
        [url] => 'http://www.mixcms.dev/notre-projet-educatif.html', 
        [parent_id] => "39", 
        [name] => 'Notre Projet Éducatif', 
        [order] => "110"
    ), 
    [12] => array(
        [id] => "38", 
        [url] => 'http://www.mixcms.dev/inscriptions.html', 
        [parent_id] => "0", 
        [name] => 'Inscriptions', 
        [order] => "120"
    ), 
    [13] => array(
        [id] => "57", 
        [url] => 'http://www.mixcms.dev/reglement-scolaire.html', 
        [parent_id] => "38", 
        [name] => 'Règlement scolaire', 
        [order] => "130"
    ), 
    [14] => array(
        [id] => "58", 
        [url] => 'http://www.mixcms.dev/reglement-financier.html', 
        [parent_id] => "38", 
        [name] => 'Règlement financier', 
        [order] => "140"
    ), 
    [15] => array(
        [id] => "37", 
        [url] => 'http://www.mixcms.dev/actualites.html', 
        [parent_id] => "0", 
        [name] => 'Actualités', 
        [order] => "150"
    ), 
    [16] => array(
        [id] => "42", 
        [url] => 'http://www.mixcms.dev/contact.html', 
        [parent_id] => "0", 
        [name] => 'Contact', 
        [order] => "160"
    ), 
    [17] => array(
        [id] => "59", 
        [url] => 'http://www.mixcms.dev/acces-pronote.html', 
        [parent_id] => "0", 
        [name] => 'Accès ProNote', 
        [order] => "170"
    )
);

你的语法错了。
print\r
和的输出,例如,只是一种表示,用于帮助您了解数组的内容。这不是有效的代码

首先,让我解开您现有的代码:

$menu_issems = array(
    [0] => array(
        [id] => "1", 
        [url] => 'http://www.mixcms.dev', 
        [parent_id] => "0", 
        [name] => 'Accueil', 
        [order] => "0"
    ), 
    [1] => array(
        [id] => "32", 
        [url] => 'http://www.mixcms.dev/nos-formations.html', 
        [parent_id] =>"0", 
        [name] => 'Nos formations', 
        [order] => "10"
    ), 
    [2] => array(
        [id] => "33", 
        [url] => 'http://www.mixcms.dev/bac-professionnel-gestion-adnimistration.html', 
        [parent_id] => "32", 
        [name] => 'Bac professionnel : GESTION ADNIMISTRATION', 
        [order] => "20"
    ), 
    [3] => array(
        [id] => 34, 
        [url] => 'http://www.mixcms.dev/bac-professionnel-arcu.html', 
        [parent_id] => 32, 
        [name] => 'Bac professionnel : ARCU', 
        [order] => "30"
    ), 
    [4] => array(
        [id] => "35", 
        [url] => 'http://www.mixcms.dev/bac-professionnel-commerce.html', 
        [parent_id] => "32", 
        [name] => 'Bac professionnel : COMMERCE', 
        [order] => "40"
    ), 
    [5] => array(
        [id] => "36", 
        [url] => 'http://www.mixcms.dev/les-marques-partenaires.html', 
        [parent_id] => 32, 
        [name] => 'Bac professionnel : VENTE', 
        [order] => 50
    ), 
    [6] => array(
        [id] => "54", 
        [url] => 'http://www.mixcms.dev/bac-professionnel-option-comptabilite-et-finance-d-rsquo-entreprise.html', 
        [parent_id] => "32", 
        [name] => 'Bac professionnel : OPTION COMPTABILITÉ ET FINANCE D’ENTREPRISE', 
        [order] => "60"
    ), 
    [7] => array(
        [id] => "55", 
        [url] => 'http://www.mixcms.dev/bac-technologique-communication-et-gestion-des-ressources-humaines.html', 
        [parent_id] => "32", 
        [name] => 'Bac technologique : COMMUNICATION ET GESTION DES RESSOURCES HUMAINES', 
        [order] => "70"
    ), 
    [8] => array(
        [id] => "39", 
        [url] => 'http://www.mixcms.dev/presentation.html', 
        [parent_id] => 0, 
        [name] => 'Présentation', 
        [order] => 80
    ), 
    [9] => array(
        [id] => 40, 
        [url] => 'http://www.mixcms.dev/historique.html', 
        [parent_id] => "39", 
        [name] => 'Historique', 
        [order] => "90"
    ), 
    [10] => array(
        [id] => "41", 
        [url] => 'http://www.mixcms.dev/nos-atouts.html', 
        [parent_id] => "39", 
        [name] => 'Nos atouts', 
        [order] => "100"
    ), 
    [11] => array(
        [id] => "56", 
        [url] => 'http://www.mixcms.dev/notre-projet-educatif.html', 
        [parent_id] => "39", 
        [name] => 'Notre Projet Éducatif', 
        [order] => "110"
    ), 
    [12] => array(
        [id] => "38", 
        [url] => 'http://www.mixcms.dev/inscriptions.html', 
        [parent_id] => "0", 
        [name] => 'Inscriptions', 
        [order] => "120"
    ), 
    [13] => array(
        [id] => "57", 
        [url] => 'http://www.mixcms.dev/reglement-scolaire.html', 
        [parent_id] => "38", 
        [name] => 'Règlement scolaire', 
        [order] => "130"
    ), 
    [14] => array(
        [id] => "58", 
        [url] => 'http://www.mixcms.dev/reglement-financier.html', 
        [parent_id] => "38", 
        [name] => 'Règlement financier', 
        [order] => "140"
    ), 
    [15] => array(
        [id] => "37", 
        [url] => 'http://www.mixcms.dev/actualites.html', 
        [parent_id] => "0", 
        [name] => 'Actualités', 
        [order] => "150"
    ), 
    [16] => array(
        [id] => "42", 
        [url] => 'http://www.mixcms.dev/contact.html', 
        [parent_id] => "0", 
        [name] => 'Contact', 
        [order] => "160"
    ), 
    [17] => array(
        [id] => "59", 
        [url] => 'http://www.mixcms.dev/acces-pronote.html', 
        [parent_id] => "0", 
        [name] => 'Accès ProNote', 
        [order] => "170"
    )
);
问题在于
[]
。对于数字,只需删除它们。对于字符串,请使用引号,如下所示:

$menu_issems = array(
    0 => array(
        "id" => "1", 
        "url" => 'http://www.mixcms.dev', 
        "parent_id" => "0", 
        "name" => 'Accueil', 
        "order" => "0"
    ), 
    1 => array(
        "id" => "32", 
        "url" => 'http://www.mixcms.dev/nos-formations.html', 
        "parent_id" =>"0", 
        "name" => 'Nos formations', 
        "order" => "10"
    ), 
    2 => array(
        "id" => "33", 
        "url" => 'http://www.mixcms.dev/bac-professionnel-gestion-adnimistration.html', 
        "parent_id" => "32", 
        "name" => 'Bac professionnel : GESTION ADNIMISTRATION', 
        "order" => "20"
    ), 
    3 => array(
        "id" => 34, 
        "url" => 'http://www.mixcms.dev/bac-professionnel-arcu.html', 
        "parent_id" => 32, 
        "name" => 'Bac professionnel : ARCU', 
        "order" => "30"
    ), 
    4 => array(
        "id" => "35", 
        "url" => 'http://www.mixcms.dev/bac-professionnel-commerce.html', 
        "parent_id" => "32", 
        "name" => 'Bac professionnel : COMMERCE', 
        "order" => "40"
    ), 
    5 => array(
        "id" => "36", 
        "url" => 'http://www.mixcms.dev/les-marques-partenaires.html', 
        "parent_id" => 32, 
        "name" => 'Bac professionnel : VENTE', 
        "order" => 50
    ), 
    6 => array(
        "id" => "54", 
        "url" => 'http://www.mixcms.dev/bac-professionnel-option-comptabilite-et-finance-d-rsquo-entreprise.html', 
        "parent_id" => "32", 
        "name" => 'Bac professionnel : OPTION COMPTABILITÉ ET FINANCE D’ENTREPRISE', 
        "order" => "60"
    ), 
    7 => array(
        "id" => "55", 
        "url" => 'http://www.mixcms.dev/bac-technologique-communication-et-gestion-des-ressources-humaines.html', 
        "parent_id" => "32", 
        "name" => 'Bac technologique : COMMUNICATION ET GESTION DES RESSOURCES HUMAINES', 
        "order" => "70"
    ), 
    8 => array(
        "id" => "39", 
        "url" => 'http://www.mixcms.dev/presentation.html', 
        "parent_id" => 0, 
        "name" => 'Présentation', 
        "order" => 80
    ), 
    9 => array(
        "id" => 40, 
        "url" => 'http://www.mixcms.dev/historique.html', 
        "parent_id" => "39", 
        "name" => 'Historique', 
        "order" => "90"
    ), 
    10 => array(
        "id" => "41", 
        "url" => 'http://www.mixcms.dev/nos-atouts.html', 
        "parent_id" => "39", 
        "name" => 'Nos atouts', 
        "order" => "100"
    ), 
    11 => array(
        "id" => "56", 
        "url" => 'http://www.mixcms.dev/notre-projet-educatif.html', 
        "parent_id" => "39", 
        "name" => 'Notre Projet Éducatif', 
        "order" => "110"
    ), 
    12 => array(
        "id" => "38", 
        "url" => 'http://www.mixcms.dev/inscriptions.html', 
        "parent_id" => "0", 
        "name" => 'Inscriptions', 
        "order" => "120"
    ), 
    13 => array(
        "id" => "57", 
        "url" => 'http://www.mixcms.dev/reglement-scolaire.html', 
        "parent_id" => "38", 
        "name" => 'Règlement scolaire', 
        "order" => "130"
    ), 
    14 => array(
        "id" => "58", 
        "url" => 'http://www.mixcms.dev/reglement-financier.html', 
        "parent_id" => "38", 
        "name" => 'Règlement financier', 
        "order" => "140"
    ), 
    15 => array(
        "id" => "37", 
        "url" => 'http://www.mixcms.dev/actualites.html', 
        "parent_id" => "0", 
        "name" => 'Actualités', 
        "order" => "150"
    ), 
    16 => array(
        "id" => "42", 
        "url" => 'http://www.mixcms.dev/contact.html', 
        "parent_id" => "0", 
        "name" => 'Contact', 
        "order" => "160"
    ), 
    17 => array(
        "id" => "59", 
        "url" => 'http://www.mixcms.dev/acces-pronote.html', 
        "parent_id" => "0", 
        "name" => 'Accès ProNote', 
        "order" => "170"
    )
);
但是,由于密钥是递增的数字,因此可以完全忽略它们:

$menu_issems = array(
    array(
        "id" => "1", 
        "url" => 'http://www.mixcms.dev', 
        "parent_id" => "0", 
        "name" => 'Accueil', 
        "order" => "0"
    ), 
    array(
        "id" => "32", 
        "url" => 'http://www.mixcms.dev/nos-formations.html', 
        "parent_id" =>"0", 
        "name" => 'Nos formations', 
        "order" => "10"
    ), 
    array(
        "id" => "33", 
        "url" => 'http://www.mixcms.dev/bac-professionnel-gestion-adnimistration.html', 
        "parent_id" => "32", 
        "name" => 'Bac professionnel : GESTION ADNIMISTRATION', 
        "order" => "20"
    ), 
    array(
        "id" => 34, 
        "url" => 'http://www.mixcms.dev/bac-professionnel-arcu.html', 
        "parent_id" => 32, 
        "name" => 'Bac professionnel : ARCU', 
        "order" => "30"
    ), 
    array(
        "id" => "35", 
        "url" => 'http://www.mixcms.dev/bac-professionnel-commerce.html', 
        "parent_id" => "32", 
        "name" => 'Bac professionnel : COMMERCE', 
        "order" => "40"
    ), 
    array(
        "id" => "36", 
        "url" => 'http://www.mixcms.dev/les-marques-partenaires.html', 
        "parent_id" => 32, 
        "name" => 'Bac professionnel : VENTE', 
        "order" => 50
    ), 
    array(
        "id" => "54", 
        "url" => 'http://www.mixcms.dev/bac-professionnel-option-comptabilite-et-finance-d-rsquo-entreprise.html', 
        "parent_id" => "32", 
        "name" => 'Bac professionnel : OPTION COMPTABILITÉ ET FINANCE D’ENTREPRISE', 
        "order" => "60"
    ), 
    array(
        "id" => "55", 
        "url" => 'http://www.mixcms.dev/bac-technologique-communication-et-gestion-des-ressources-humaines.html', 
        "parent_id" => "32", 
        "name" => 'Bac technologique : COMMUNICATION ET GESTION DES RESSOURCES HUMAINES', 
        "order" => "70"
    ), 
    array(
        "id" => "39", 
        "url" => 'http://www.mixcms.dev/presentation.html', 
        "parent_id" => 0, 
        "name" => 'Présentation', 
        "order" => 80
    ), 
    array(
        "id" => 40, 
        "url" => 'http://www.mixcms.dev/historique.html', 
        "parent_id" => "39", 
        "name" => 'Historique', 
        "order" => "90"
    ), 
    array(
        "id" => "41", 
        "url" => 'http://www.mixcms.dev/nos-atouts.html', 
        "parent_id" => "39", 
        "name" => 'Nos atouts', 
        "order" => "100"
    ), 
    array(
        "id" => "56", 
        "url" => 'http://www.mixcms.dev/notre-projet-educatif.html', 
        "parent_id" => "39", 
        "name" => 'Notre Projet Éducatif', 
        "order" => "110"
    ), 
    array(
        "id" => "38", 
        "url" => 'http://www.mixcms.dev/inscriptions.html', 
        "parent_id" => "0", 
        "name" => 'Inscriptions', 
        "order" => "120"
    ), 
    array(
        "id" => "57", 
        "url" => 'http://www.mixcms.dev/reglement-scolaire.html', 
        "parent_id" => "38", 
        "name" => 'Règlement scolaire', 
        "order" => "130"
    ), 
    array(
        "id" => "58", 
        "url" => 'http://www.mixcms.dev/reglement-financier.html', 
        "parent_id" => "38", 
        "name" => 'Règlement financier', 
        "order" => "140"
    ), 
    array(
        "id" => "37", 
        "url" => 'http://www.mixcms.dev/actualites.html', 
        "parent_id" => "0", 
        "name" => 'Actualités', 
        "order" => "150"
    ), 
    array(
        "id" => "42", 
        "url" => 'http://www.mixcms.dev/contact.html', 
        "parent_id" => "0", 
        "name" => 'Contact', 
        "order" => "160"
    ), 
    array(
        "id" => "59", 
        "url" => 'http://www.mixcms.dev/acces-pronote.html', 
        "parent_id" => "0", 
        "name" => 'Accès ProNote', 
        "order" => "170"
    )
);

请给我们看你的代码,它从你的脚本中获取菜单。它的抛出错误与该代码你的数组声明语法是错误的。。。这看起来像php
数组的
print\u r
var\u dump
这是您真正的数组吗??或
var\u dump
print\u r
?它是一个print r代码