{"id":635,"date":"2012-09-09T21:52:56","date_gmt":"2012-09-09T19:52:56","guid":{"rendered":"https:\/\/d-mueller.de\/blog\/?p=635"},"modified":"2016-01-11T23:20:45","modified_gmt":"2016-01-11T22:20:45","slug":"php-wtf-8","status":"publish","type":"post","link":"https:\/\/d-mueller.de\/blog\/php-wtf-8\/","title":{"rendered":"PHP WTF #8"},"content":{"rendered":"<pre data-enlighter-language=\"php\" class=\"EnlighterJSRAW\">\r\n$array = array(true, null);\r\n\r\nvar_dump(in_array(&#039;&#039;, $array)); \/\/ true\r\nvar_dump(in_array(0, $array)); \/\/ true\r\nvar_dump(in_array(763, $array)); \/\/ true\r\nvar_dump(in_array(&#039;cheese&#039;, $array)); \/\/ true\r\nvar_dump(in_array(new stdClass(), $array)); \/\/ true\r\nvar_dump(in_array([], $array)); \/\/ true\r\n<\/pre>\n<p>Tja, PHP und seine automatische Typumwandlung. Wahnsinn, was so alles in dem Array drin ist! <a href=\"http:\/\/php.net\/manual\/de\/function.in-array.php\">in_array<\/a> bitte nur mit dem dritten Parameter <b>strict<\/b> auf <i>true<\/i> benutzen. Sollte ohnehin default sein.<\/p>\n<pre data-enlighter-language=\"enlighter\" class=\"EnlighterJSRAW\">\r\nbool in_array ( mixed $needle , array $haystack [, bool $strict = FALSE ] )\r\n<\/pre>\n<p>Schon besser:<\/p>\n<pre data-enlighter-language=\"php\" class=\"EnlighterJSRAW\">\r\n$array = array(true, null);\r\n\r\nvar_dump(in_array(&#039;&#039;, $array, true)); \/\/ false\r\nvar_dump(in_array(0, $array, true)); \/\/ false\r\nvar_dump(in_array(763, $array, true)); \/\/ false\r\nvar_dump(in_array(&#039;cheese&#039;, $array, true)); \/\/ false\r\nvar_dump(in_array(new stdClass(), $array, true)); \/\/ false\r\nvar_dump(in_array([], $array, true)); \/\/ false\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>$array = array(true, null); var_dump(in_array(&#039;&#039;, $array)); \/\/ true var_dump(in_array(0, $array)); \/\/ true var_dump(in_array(763, $array)); \/\/ true var_dump(in_array(&#039;cheese&#039;, $array)); \/\/ true var_dump(in_array(new stdClass(), $array)); \/\/ true var_dump(in_array([], $array)); \/\/ true Tja, PHP und seine automatische Typumwandlung. Wahnsinn, was so alles in &hellip; <a href=\"https:\/\/d-mueller.de\/blog\/php-wtf-8\/\">Weiterlesen <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,14,3],"tags":[],"class_list":["post-635","post","type-post","status-publish","format-standard","hentry","category-php","category-php-wtf","category-webdev"],"_links":{"self":[{"href":"https:\/\/d-mueller.de\/blog\/wp-json\/wp\/v2\/posts\/635","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/d-mueller.de\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/d-mueller.de\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/d-mueller.de\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/d-mueller.de\/blog\/wp-json\/wp\/v2\/comments?post=635"}],"version-history":[{"count":0,"href":"https:\/\/d-mueller.de\/blog\/wp-json\/wp\/v2\/posts\/635\/revisions"}],"wp:attachment":[{"href":"https:\/\/d-mueller.de\/blog\/wp-json\/wp\/v2\/media?parent=635"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/d-mueller.de\/blog\/wp-json\/wp\/v2\/categories?post=635"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/d-mueller.de\/blog\/wp-json\/wp\/v2\/tags?post=635"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}