{"id":2660,"date":"2025-10-09T08:00:00","date_gmt":"2025-10-09T06:00:00","guid":{"rendered":"https:\/\/www.fuhselab.de\/?p=2660"},"modified":"2025-04-17T09:30:23","modified_gmt":"2025-04-17T07:30:23","slug":"php-und-arrays-1","status":"publish","type":"post","link":"https:\/\/www.fuhselab.de\/index.php\/2025\/10\/09\/php-und-arrays-1\/","title":{"rendered":"PHP und Arrays 1:"},"content":{"rendered":"\n<p><br>Die Schleifen sind erledigt und jetzt geht es an die Feldvariablen \u2013 die auch Array genannt werden\u2026<\/p>\n\n\n\n<!--more-->\n\n\n\n<p><strong>Vorbereitungen:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>In der localhost-Umgebung erstelle ich den Ordner f\u00fcr dieses Kapitel<\/li>\n\n\n\n<li>Erstellen der Datei array01.php<\/li>\n\n\n\n<li>PHP-Code in einen Artikel einf\u00fcgen\u2026<\/li>\n<\/ul>\n\n\n\n<p><strong>Das einfache Array:<\/strong><\/p>\n\n\n\n<p>Das erste einfachste Array wird nun gleich in den ersten Artikel eingef\u00fcgt.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?php\n$wochentage = array(\"Sonntag\",\"Montag\",\"Dienstag\",\n\"Mittwoch\",\"Donnerstag\",\"Freitag\",\"Samstag\");\necho $wochentage&#91;1];\n?><\/code><\/pre>\n\n\n\n<p><br>Das folgende zweite Beispiel ist nur eine Variation und speichert die Array-Werte in einzelnen Variablen.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?php\n$staedte = array(\"Peine\", \"Hamburg\", \"Kassel\");\n\n$stadt01 = $staedte&#91;0];\n$stadt02 = $staedte&#91;1];\n$stadt03 = $staedte&#91;2];\n\necho \"&lt;br \/>&lt;br \/>\";\necho \"$stadt01\";\n\necho \"&lt;br \/>&lt;br \/>\";\necho \"$stadt02\";\n\necho \"&lt;br \/>&lt;br \/>\";\necho \"$stadt03\";\n?><\/code><\/pre>\n\n\n\n<p><strong>Das assoziative Array:<\/strong><\/p>\n\n\n\n<p>Um sich nicht immer die Indexwerte merken zu m\u00fcssen oder sie nicht immer abz\u00e4hlen zu m\u00fcssen, k\u00f6nnen auch Schl\u00fcsselwerte dem Arrayeintr\u00e4gen zugewiesen werden.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?php\n$wochentage = array(\n\"so\" => \"Sonntag\",\n\"mo\" => \"Montag\",\n\"di\" => \"Dienstag\",\n\"mi\" => \"Mittwoch\",\n\"do\" => \"Donnerstag\",\n\"fr\" => \"Freitag\",\n\"sa\" => \"Samstag\");\necho $wochentage&#91;\"mo\"];\n?><\/code><\/pre>\n\n\n\n<p><strong>Ausblick:<\/strong><\/p>\n\n\n\n<p>Im n\u00e4chsten PHP Artikel geht es mit Arrays weiter. Es werden Werte zugef\u00fcgt und ge\u00e4ndert. Abschlie\u00dfend wird auch ein mehrdimensionales Array vorgestellt&#8230;<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Die Schleifen sind erledigt und jetzt geht es an die Feldvariablen \u2013 die auch Array genannt werden\u2026<\/p>\n","protected":false},"author":1,"featured_media":543,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[33],"tags":[32],"class_list":["post-2660","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-coding-club","tag-coding-club-peine"],"_links":{"self":[{"href":"https:\/\/www.fuhselab.de\/index.php\/wp-json\/wp\/v2\/posts\/2660","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.fuhselab.de\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.fuhselab.de\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.fuhselab.de\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.fuhselab.de\/index.php\/wp-json\/wp\/v2\/comments?post=2660"}],"version-history":[{"count":1,"href":"https:\/\/www.fuhselab.de\/index.php\/wp-json\/wp\/v2\/posts\/2660\/revisions"}],"predecessor-version":[{"id":2661,"href":"https:\/\/www.fuhselab.de\/index.php\/wp-json\/wp\/v2\/posts\/2660\/revisions\/2661"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.fuhselab.de\/index.php\/wp-json\/wp\/v2\/media\/543"}],"wp:attachment":[{"href":"https:\/\/www.fuhselab.de\/index.php\/wp-json\/wp\/v2\/media?parent=2660"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.fuhselab.de\/index.php\/wp-json\/wp\/v2\/categories?post=2660"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.fuhselab.de\/index.php\/wp-json\/wp\/v2\/tags?post=2660"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}