{"id":1990,"date":"2018-08-01T13:58:23","date_gmt":"2018-08-01T11:58:23","guid":{"rendered":"https:\/\/vielhuber.de\/?p=1990"},"modified":"2020-09-13T21:27:42","modified_gmt":"2020-09-13T19:27:42","slug":"bug-in-assoziativen-arrays-in-php","status":"publish","type":"post","link":"https:\/\/vielhuber.de\/blog\/bug-in-assoziativen-arrays-in-php\/","title":{"rendered":"Bug in assoziativen Arrays in PHP &lt;7.2"},"content":{"rendered":"<p>In PHP &lt;7.2 kann man Arrays erzeugen, auf die man nicht mehr richtig zugreifen kann:<\/p>\n<p class=\"githubgist\" data-gist-file=\"1.php\">91367d1c4636fd753b381406024e303c<\/p>\n<p>Damit kann man nun einige Sachen machen.<\/p>\n<p><!--more--><\/p>\n<p class=\"githubgist\" data-gist-file=\"2.php\">91367d1c4636fd753b381406024e303c<\/p>\n<p>Die Wurzel allen \u00dcbels liegt im Bug <a href=\"https:\/\/bugs.php.net\/bug.php?id=61655\" target=\"_blank\" rel=\"noopener noreferrer\">#61655<\/a>. Als Workaround macht man aus dem vermurksten Array wieder ein Objekt und castet es auf einem anderen Weg:<\/p>\n<p class=\"githubgist\" data-gist-file=\"3.php\">91367d1c4636fd753b381406024e303c<\/p>\n<p>Oder man verzichtet gleich ganz auf numerischen Strings als Keys \u2013 PHP castet ohnehin jeden numerischen String als Key eines assoziativen Arrays als Integer.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In PHP &lt;7.2 kann man Arrays erzeugen, auf die man nicht mehr richtig zugreifen kann: 91367d1c4636fd753b381406024e303c Damit kann man nun einige Sachen machen.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"gtbabel_prevent_lngs":"","gtbabel_alt_lng":"","footnotes":""},"categories":[1],"tags":[],"class_list":{"0":"post-1990","1":"post","2":"type-post","3":"status-publish","4":"format-standard","6":"category-blog"},"acf":[],"yoast_head":"<title>Bug in assoziativen Arrays in PHP &lt;7.2 &#060; Vielhuber David<\/title>\n<meta name=\"description\" content=\"In PHP &lt;7.2 kann man Arrays erzeugen, auf die man nicht mehr richtig zugreifen kann: 91367d1c4636fd753b381406024e303c Damit kann man nun einige Sac...\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/vielhuber.de\/blog\/bug-in-assoziativen-arrays-in-php\/\" \/>\n<meta property=\"og:locale\" content=\"de_DE\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Bug in assoziativen Arrays in PHP &lt;7.2 &#060; Vielhuber David\" \/>\n<meta property=\"og:description\" content=\"In PHP &lt;7.2 kann man Arrays erzeugen, auf die man nicht mehr richtig zugreifen kann: 91367d1c4636fd753b381406024e303c Damit kann man nun einige Sachen\" \/>\n<meta property=\"og:url\" content=\"https:\/\/vielhuber.de\/blog\/bug-in-assoziativen-arrays-in-php\/\" \/>\n<meta property=\"og:site_name\" content=\"Vielhuber David\" \/>\n<meta property=\"article:published_time\" content=\"2018-08-01T11:58:23+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2020-09-13T19:27:42+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/vielhuber.de\/wp-content\/uploads\/about.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"700\" \/>\n\t<meta property=\"og:image:height\" content=\"552\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"David\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@vielhuber\" \/>\n<meta name=\"twitter:site\" content=\"@vielhuber\" \/>\n<meta name=\"twitter:label1\" content=\"Verfasst von\" \/>\n\t<meta name=\"twitter:data1\" content=\"David\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/vielhuber.de\\\/blog\\\/bug-in-assoziativen-arrays-in-php\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/vielhuber.de\\\/blog\\\/bug-in-assoziativen-arrays-in-php\\\/\"},\"author\":{\"name\":\"David\",\"@id\":\"https:\\\/\\\/vielhuber.de\\\/#\\\/schema\\\/person\\\/64d4ff14713d413ea4d9b210d0c2c6ef\"},\"headline\":\"Bug in assoziativen Arrays in PHP &lt;7.2\",\"datePublished\":\"2018-08-01T11:58:23+00:00\",\"dateModified\":\"2020-09-13T19:27:42+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/vielhuber.de\\\/blog\\\/bug-in-assoziativen-arrays-in-php\\\/\"},\"wordCount\":95,\"publisher\":{\"@id\":\"https:\\\/\\\/vielhuber.de\\\/#\\\/schema\\\/person\\\/64d4ff14713d413ea4d9b210d0c2c6ef\"},\"articleSection\":[\"Blog\"],\"inLanguage\":\"de\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/vielhuber.de\\\/blog\\\/bug-in-assoziativen-arrays-in-php\\\/\",\"url\":\"https:\\\/\\\/vielhuber.de\\\/blog\\\/bug-in-assoziativen-arrays-in-php\\\/\",\"name\":\"Bug in assoziativen Arrays in PHP &lt;7.2 &#060; Vielhuber David\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/vielhuber.de\\\/#website\"},\"datePublished\":\"2018-08-01T11:58:23+00:00\",\"dateModified\":\"2020-09-13T19:27:42+00:00\",\"description\":\"In PHP &lt;7.2 kann man Arrays erzeugen, auf die man nicht mehr richtig zugreifen kann: 91367d1c4636fd753b381406024e303c Damit kann man nun einige Sachen\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/vielhuber.de\\\/blog\\\/bug-in-assoziativen-arrays-in-php\\\/#breadcrumb\"},\"inLanguage\":\"de\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/vielhuber.de\\\/blog\\\/bug-in-assoziativen-arrays-in-php\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/vielhuber.de\\\/blog\\\/bug-in-assoziativen-arrays-in-php\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/vielhuber.de\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Bug in assoziativen Arrays in PHP &lt;7.2\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/vielhuber.de\\\/#website\",\"url\":\"https:\\\/\\\/vielhuber.de\\\/\",\"name\":\"Vielhuber David\",\"description\":\"Full-Stack Developer\",\"publisher\":{\"@id\":\"https:\\\/\\\/vielhuber.de\\\/#\\\/schema\\\/person\\\/64d4ff14713d413ea4d9b210d0c2c6ef\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/vielhuber.de\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"de\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/vielhuber.de\\\/#\\\/schema\\\/person\\\/64d4ff14713d413ea4d9b210d0c2c6ef\",\"name\":\"David\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"de\",\"@id\":\"https:\\\/\\\/vielhuber.de\\\/wp-content\\\/uploads\\\/about.jpg\",\"url\":\"https:\\\/\\\/vielhuber.de\\\/wp-content\\\/uploads\\\/about.jpg\",\"contentUrl\":\"https:\\\/\\\/vielhuber.de\\\/wp-content\\\/uploads\\\/about.jpg\",\"width\":700,\"height\":552,\"caption\":\"David\"},\"logo\":{\"@id\":\"https:\\\/\\\/vielhuber.de\\\/wp-content\\\/uploads\\\/about.jpg\"},\"sameAs\":[\"https:\\\/\\\/x.com\\\/vielhuber\"]}]}<\/script>","yoast_head_json":{"title":"Bug in assoziativen Arrays in PHP &lt;7.2 &#060; Vielhuber David","description":"In PHP &lt;7.2 kann man Arrays erzeugen, auf die man nicht mehr richtig zugreifen kann: 91367d1c4636fd753b381406024e303c Damit kann man nun einige Sac...","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/vielhuber.de\/blog\/bug-in-assoziativen-arrays-in-php\/","og_locale":"de_DE","og_type":"article","og_title":"Bug in assoziativen Arrays in PHP &lt;7.2 &#060; Vielhuber David","og_description":"In PHP &lt;7.2 kann man Arrays erzeugen, auf die man nicht mehr richtig zugreifen kann: 91367d1c4636fd753b381406024e303c Damit kann man nun einige Sachen","og_url":"https:\/\/vielhuber.de\/blog\/bug-in-assoziativen-arrays-in-php\/","og_site_name":"Vielhuber David","article_published_time":"2018-08-01T11:58:23+00:00","article_modified_time":"2020-09-13T19:27:42+00:00","og_image":[{"width":700,"height":552,"url":"https:\/\/vielhuber.de\/wp-content\/uploads\/about.jpg","type":"image\/jpeg"}],"author":"David","twitter_card":"summary_large_image","twitter_creator":"@vielhuber","twitter_site":"@vielhuber","twitter_misc":{"Verfasst von":"David"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/vielhuber.de\/blog\/bug-in-assoziativen-arrays-in-php\/#article","isPartOf":{"@id":"https:\/\/vielhuber.de\/blog\/bug-in-assoziativen-arrays-in-php\/"},"author":{"name":"David","@id":"https:\/\/vielhuber.de\/#\/schema\/person\/64d4ff14713d413ea4d9b210d0c2c6ef"},"headline":"Bug in assoziativen Arrays in PHP &lt;7.2","datePublished":"2018-08-01T11:58:23+00:00","dateModified":"2020-09-13T19:27:42+00:00","mainEntityOfPage":{"@id":"https:\/\/vielhuber.de\/blog\/bug-in-assoziativen-arrays-in-php\/"},"wordCount":95,"publisher":{"@id":"https:\/\/vielhuber.de\/#\/schema\/person\/64d4ff14713d413ea4d9b210d0c2c6ef"},"articleSection":["Blog"],"inLanguage":"de"},{"@type":"WebPage","@id":"https:\/\/vielhuber.de\/blog\/bug-in-assoziativen-arrays-in-php\/","url":"https:\/\/vielhuber.de\/blog\/bug-in-assoziativen-arrays-in-php\/","name":"Bug in assoziativen Arrays in PHP &lt;7.2 &#060; Vielhuber David","isPartOf":{"@id":"https:\/\/vielhuber.de\/#website"},"datePublished":"2018-08-01T11:58:23+00:00","dateModified":"2020-09-13T19:27:42+00:00","description":"In PHP &lt;7.2 kann man Arrays erzeugen, auf die man nicht mehr richtig zugreifen kann: 91367d1c4636fd753b381406024e303c Damit kann man nun einige Sachen","breadcrumb":{"@id":"https:\/\/vielhuber.de\/blog\/bug-in-assoziativen-arrays-in-php\/#breadcrumb"},"inLanguage":"de","potentialAction":[{"@type":"ReadAction","target":["https:\/\/vielhuber.de\/blog\/bug-in-assoziativen-arrays-in-php\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/vielhuber.de\/blog\/bug-in-assoziativen-arrays-in-php\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/vielhuber.de\/"},{"@type":"ListItem","position":2,"name":"Bug in assoziativen Arrays in PHP &lt;7.2"}]},{"@type":"WebSite","@id":"https:\/\/vielhuber.de\/#website","url":"https:\/\/vielhuber.de\/","name":"Vielhuber David","description":"Full-Stack Developer","publisher":{"@id":"https:\/\/vielhuber.de\/#\/schema\/person\/64d4ff14713d413ea4d9b210d0c2c6ef"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/vielhuber.de\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"de"},{"@type":["Person","Organization"],"@id":"https:\/\/vielhuber.de\/#\/schema\/person\/64d4ff14713d413ea4d9b210d0c2c6ef","name":"David","image":{"@type":"ImageObject","inLanguage":"de","@id":"https:\/\/vielhuber.de\/wp-content\/uploads\/about.jpg","url":"https:\/\/vielhuber.de\/wp-content\/uploads\/about.jpg","contentUrl":"https:\/\/vielhuber.de\/wp-content\/uploads\/about.jpg","width":700,"height":552,"caption":"David"},"logo":{"@id":"https:\/\/vielhuber.de\/wp-content\/uploads\/about.jpg"},"sameAs":["https:\/\/x.com\/vielhuber"]}]}},"_links":{"self":[{"href":"https:\/\/vielhuber.de\/ar\/wp-json\/wp\/v2\/posts\/1990","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/vielhuber.de\/ar\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/vielhuber.de\/ar\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/vielhuber.de\/ar\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/vielhuber.de\/ar\/wp-json\/wp\/v2\/comments?post=1990"}],"version-history":[{"count":11,"href":"https:\/\/vielhuber.de\/ar\/wp-json\/wp\/v2\/posts\/1990\/revisions"}],"predecessor-version":[{"id":2750,"href":"https:\/\/vielhuber.de\/ar\/wp-json\/wp\/v2\/posts\/1990\/revisions\/2750"}],"wp:attachment":[{"href":"https:\/\/vielhuber.de\/ar\/wp-json\/wp\/v2\/media?parent=1990"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/vielhuber.de\/ar\/wp-json\/wp\/v2\/categories?post=1990"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/vielhuber.de\/ar\/wp-json\/wp\/v2\/tags?post=1990"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}