{"id":2006,"date":"2016-10-19T21:31:05","date_gmt":"2016-10-19T21:31:05","guid":{"rendered":"http:\/\/www.kodcafe.com\/?p=2006"},"modified":"2016-10-19T21:31:05","modified_gmt":"2016-10-19T21:31:05","slug":"php-de-dizi-tanimlama","status":"publish","type":"post","link":"https:\/\/www.kodcafe.com\/?p=2006","title":{"rendered":"Php de Dizi Tan\u0131mlama"},"content":{"rendered":"<p>Diziler, i\u00e7erisinde bir\u00e7ok de\u011fer saklanabilen de\u011fi\u015fkenler k\u00fcmesi olarak adland\u0131r\u0131labilir. \u00d6rne\u011fin 10 ki\u015filik bir s\u0131n\u0131fta bir derse ait vize notlar\u0131n\u0131 saklamak i\u00e7in 10 tane de\u011fi\u015fken tan\u0131mlamak yerine bir dizi tan\u0131mlay\u0131p notlar\u0131 diziye aktarmak daha pratik bir kullan\u0131md\u0131r.<\/p>\n<p>Diziler index (key, indis)dedi\u011fimiz de\u011ferlerde saklan\u0131r.. \u00e7a\u011f\u0131rmak i\u00e7in $dizi[0] de\u011ferini getir gibi kullanabiliriz.<!--more--><\/p>\n<pre lang=\"php\">\n<!--?php $ogrenciler = array(\"Ay\u015fe\", \"Mehmet\", \"Hatice\", \"Ali\"); ?--> \n\nDizileri array() fonksiyonunu kullanmadan tan\u0131mlamak m\u00fcmk\u00fcnd\u00fcr. \n\n<!--?php $ogrenciler[0] = \"Ay\u015fe\"; $ogrenciler[1] = \"Mehmet\"; $ogrenciler[2] = \"Hatice\"; $ogrenciler[3] = \"Ali\"; ?--> \n\n\u00d6RNEK KULLANIM2 : \n\n<!--?php \/\/ Anahtarlar\u0131 kendimiz tan\u0131mlayal\u0131m $ogrenciler = array( \"Ad\u0131\" =&gt; \"Ali\", \"Soyad\u0131\" =&gt; \"veli\", \"No\" =&gt; \"123456766\"); ?--> \n\n<!--?php \/\/ Ayn\u0131 diziyi Array() fonksiyonunu kullanmadan tan\u0131mlayal\u0131m $ogrenciler[\"Ad\u0131\"] = \"Ali\"; $ogrenciler[\"Soyad\u0131\"] = \"veli\"; $ogrenciler[\"No\"] = \"123456766\"; ?-->\n\n<\/pre>\n<p>Dizi elemanlar\u0131n\u0131 yazd\u0131rmak i\u00e7in bir ka\u00e7 farkl\u0131 yol vard\u0131r. Bunlardan en \u00e7ok kullan\u0131lan\u0131 <strong>foreach<\/strong> d\u00f6ng\u00fcs\u00fcd\u00fcr. Foreach d\u00f6ng\u00fcs\u00fcnde dizinin ka\u00e7 elemanl\u0131 oldu\u011funu belirmenize gerek yoktur. \u00c7\u00fcnk\u00fc bu d\u00f6ng\u00fc kural\u0131nda kendisi hesaplar. Ama di\u011fer d\u00f6ng\u00fclerde dizinin ka\u00e7 elamanl\u0131 oldu\u011funu belirtmeniz gerekmektedir. Bunun i\u00e7in <strong>count()<\/strong> komutu kullanabilirsiniz.. E\u011fer count() komutu kullanmayacaksan\u0131z d\u00f6ng\u00fclerde while d\u00f6ng\u00fcs\u00fcnde <strong>$dizi[i]!= null<\/strong> gibi \u015fartlar ko\u015farak da d\u00f6ng\u00fc alternatifi kurabilirsiniz.. <\/p>\n<pre lang=\"php\">\n\/\/d\u00f6ng\u00fcs\u00fcz yazd\u0131rmak i\u00e7in\n<?php\n$dizi=array(\"A\",\"B\",\"C\");\n\necho $dizi[0].\"<br>\";\necho $dizi[1].\"<br>\";\necho $dizi[2].\"<br>\";\n\nprint_r($dizi);\n?>\n\n\/\/ d\u00f6ng\u00fc ile yazd\u0131rmak i\u00e7in\n\n<?php\n$dizi=array(\"A\",\"B\",\"C\");\n\nforeach($dizi as $deger)\n{\n\techo $deger.\"<br>\";\n}\n?>\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Diziler, i\u00e7erisinde bir\u00e7ok de\u011fer saklanabilen de\u011fi\u015fkenler k\u00fcmesi olarak adland\u0131r\u0131labilir. \u00d6rne\u011fin 10 ki\u015filik bir s\u0131n\u0131fta bir derse ait vize notlar\u0131n\u0131 saklamak i\u00e7in 10 tane de\u011fi\u015fken tan\u0131mlamak yerine bir dizi tan\u0131mlay\u0131p notlar\u0131 diziye aktarmak daha pratik bir kullan\u0131md\u0131r. Diziler index (key, indis)dedi\u011fimiz de\u011ferlerde saklan\u0131r.. \u00e7a\u011f\u0131rmak i\u00e7in $dizi[0] de\u011ferini getir gibi kullanabiliriz.<\/p>\n","protected":false},"author":1,"featured_media":101,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[23],"tags":[105,318,322],"class_list":["post-2006","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-php","tag-diziler","tag-php-2","tag-php-de-diziler"],"_links":{"self":[{"href":"https:\/\/www.kodcafe.com\/index.php?rest_route=\/wp\/v2\/posts\/2006","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.kodcafe.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.kodcafe.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.kodcafe.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.kodcafe.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2006"}],"version-history":[{"count":0,"href":"https:\/\/www.kodcafe.com\/index.php?rest_route=\/wp\/v2\/posts\/2006\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.kodcafe.com\/index.php?rest_route=\/"}],"wp:attachment":[{"href":"https:\/\/www.kodcafe.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2006"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.kodcafe.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2006"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.kodcafe.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2006"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}