{"id":825,"date":"2023-12-04T08:00:00","date_gmt":"2023-12-04T07:00:00","guid":{"rendered":"https:\/\/www.fuhselab.de\/?p=825"},"modified":"2024-07-24T06:17:15","modified_gmt":"2024-07-24T04:17:15","slug":"php-workshop-11","status":"publish","type":"post","link":"https:\/\/www.fuhselab.de\/index.php\/2023\/12\/04\/php-workshop-11\/","title":{"rendered":"PHP Workshop 11"},"content":{"rendered":"\n<p>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>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$stadt01 = $staedte&#91;0];\n$stadt02 = $staedte&#91;1];\n$stadt03 = $staedte&#91;2];\necho \"&lt;br \/>&lt;br \/>\";\necho \"$stadt01\";\necho \"&lt;br \/>&lt;br \/>\";\necho \"$stadt02\";\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","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":53,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[23],"class_list":["post-825","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-webdesign","tag-webdesign-gruppe-peine"],"_links":{"self":[{"href":"https:\/\/www.fuhselab.de\/index.php\/wp-json\/wp\/v2\/posts\/825","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=825"}],"version-history":[{"count":2,"href":"https:\/\/www.fuhselab.de\/index.php\/wp-json\/wp\/v2\/posts\/825\/revisions"}],"predecessor-version":[{"id":1688,"href":"https:\/\/www.fuhselab.de\/index.php\/wp-json\/wp\/v2\/posts\/825\/revisions\/1688"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.fuhselab.de\/index.php\/wp-json\/wp\/v2\/media\/53"}],"wp:attachment":[{"href":"https:\/\/www.fuhselab.de\/index.php\/wp-json\/wp\/v2\/media?parent=825"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.fuhselab.de\/index.php\/wp-json\/wp\/v2\/categories?post=825"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.fuhselab.de\/index.php\/wp-json\/wp\/v2\/tags?post=825"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}