PHP Array Data Type - Indexed, Associative & Multi-Dimensional Arrays - Full PHP 8 Tutorial

Поділитися
Вставка
  • Опубліковано 1 лип 2024
  • In PHP you can have regular index-based arrays also known as indexed arrays, you could also have arrays with custom keys also known as associative arrays & can have arrays within arrays which are called multi-dimensional arrays. You will learn all that you need to know about arrays to get started using them goes over how arrays are indexed by default & how re-indexing happens. Also, you will learn how to check if an element exists in an array at the specific key & the difference between array_key_exists & isset().
    SOME OF THE WAYS YOU CAN SUPPORT THE CHANNEL
    👍 Smash the like button
    🤝 Subscribe to the channel & turn the notifications on
    💬 Post comments, any feedback is greatly appreciated
    ⭐ Become a Patreon: / programwithgio
    THANK YOU!
    LESSON 1.10
    Course Outline - github.com/ggelashvili/learnp...
    Course Playlist - • Learn PHP The Right Wa...
    CHAPTERS
    00:00 - Intro
    00:43 - What are arrays
    01:27 - Indexed arrays & accessing elements
    03:06 - Undefined array key
    03:41 - Check if array key exists - isset()
    04:04 - Mutate arrays
    04:52 - Get length of array - count()
    05:04 - Add elements to an array - square bracket syntax
    05:37 - Add multiple elements to an array using array_push
    06:05 - Name your keys (associative arrays)
    07:11 - Add elements to associative arrays at specified keys
    07:45 - Multi-dimensional arrays
    10:02 - Duplicate keys & overwriting
    11:18 - Having keys on only some elements & how automatic indexing works
    12:05 - Removing an element from the end of an array using array_pop
    12:27 - Removing an element from the beginning of an array using array_shift & re-indexing
    13:14 - Removing element(s) from arrays by specifying keys using unset
    13:59 - Using unset() does not re-index arrays
    15:00 - Casting to arrays
    15:27 - Another way to check if the key exists in array & the difference between array_key_exists & isset()

КОМЕНТАРІ • 176

  • @colonelvector
    @colonelvector Рік тому +16

    I've never seen a tutorial so quick yet thorough and understandable at the same time. You covered everything in such a short amount of time while keeping it clear.
    Excellent, excellent video. The whole series actually. This would be my go-to suggestion for new or experinced devs

    • @ProgramWithGio
      @ProgramWithGio  Рік тому +1

      This means alot, thank you 💙. The video speed was an editing mistake I made early on in the series :). I cut out all the empty spaces that make it sound like I don't breathe.

  • @magnomani5865
    @magnomani5865 Рік тому +4

    This is not a course about how to program in PHP, but how to do it with love and best right way!
    Thanks forever!

  • @timiade8108
    @timiade8108 3 роки тому +1

    Thanks. Very good explanation

  • @guxtavp
    @guxtavp 2 роки тому

    Wow you showed me everything behind arrays in php. thank you so much! nice videos.

    • @ProgramWithGio
      @ProgramWithGio  2 роки тому

      Glad it was helpful! You're welcome & thank you 💙

  • @Wai78_
    @Wai78_ 9 місяців тому

    WOW !
    To the point , understandable , really really great !

  • @snakemanluffy7645
    @snakemanluffy7645 3 роки тому +3

    Amazing in-depth lecture. :D Thanks

  • @hexdom2269
    @hexdom2269 2 роки тому +1

    This course and channel is WAY underrated. Good job with your videos man!

  • @CartmanMthrFckr
    @CartmanMthrFckr 2 роки тому

    This is a really well made course, thank you!

  • @sampulcodemine
    @sampulcodemine 3 роки тому +2

    Thank you very much for the time and effort to give this great piece a little or no cost. It is precise, simple. Thanks once again.

  • @nielsmartens307
    @nielsmartens307 2 роки тому +1

    Thanks for this amazing video! They don't teach it like this in school.

  • @miguelacosta707
    @miguelacosta707 3 роки тому +6

    Great series, keep going.

  • @averageProgrammer
    @averageProgrammer Рік тому +4

    I love your tutorials, clear and concise, and straight to the point, thank you so much for bringing out this series. If it's possible please bring a series just like this on the Laravel framework, I'll be happy to support you.

  • @ballpen9157
    @ballpen9157 Рік тому

    I didn't know php evolve a lot. great vid. thanks.

  • @manolisgkoulias8290
    @manolisgkoulias8290 3 роки тому +16

    You are doing a great job, I ll definetely recomend this series to others.

  • @arturkhachatryan63
    @arturkhachatryan63 3 роки тому +4

    thank you for the lesson

  • @jewgienijbrzozowski8451
    @jewgienijbrzozowski8451 2 роки тому +1

    Best stuff for learning php I got in to so far! I must say I feel lucky I got here somehow.

  • @jessieren6476
    @jessieren6476 2 роки тому

    This is the second time I have watched this video. And I have a deeper understanding of some knowledge.

  • @alexandershnaidman8188
    @alexandershnaidman8188 8 місяців тому

    So much usefull stuff, up to all details 👍👍

  • @RakibulIslam-cp8oi
    @RakibulIslam-cp8oi 9 місяців тому

    I had never seen this kind of informative video about arrays.
    Love from Bangladesh.

  • @ShinigamiAnger
    @ShinigamiAnger 3 роки тому +23

    This series is so well done, I'm amazed. Well paced, well explained, and so complete, there are infos that I couldn't find in any other course, probably not for total beginners, but definitely of a quality that is very rare to find.

    • @ProgramWithGio
      @ProgramWithGio  3 роки тому +4

      That's great to hear, thank you so much. First section of the course which is videos numbered 1.* are beginner-friendly so I think it should not be too hard for total beginners to follow. Do you mean by total beginners as someone who has no prior coding experience at all & is starting with PHP? If that's the case then I would agree that it might be a bit harder but should still be able to pick it up, might need to rewatch some videos multiple times though.

    • @ShinigamiAnger
      @ShinigamiAnger 3 роки тому +3

      @@ProgramWithGio Hi, yes exactly, sorry for being unclear, but I didn't mean it in a negative way, the quality is truly mind blowing, I'm sure that by following along with practice this is a perfect course for everyone. I'm already familiar with php, but with all the informations in this course I feel like finally going to the next level, I can see a lot of details that I have been missing and concepts that were unknown to me. I can't thank you enough and I wish you all the best.

    • @ProgramWithGio
      @ProgramWithGio  3 роки тому +2

      No worries, I didn't think it was negative in any way, I'm always open for feedback. Thank you so much 🙏. Glad you found my videos helpful

  • @SynMlyn
    @SynMlyn 5 місяців тому

    A big shoutout to Gio for his generosity in sharing his PHP expertise!

  • @cibertwin5356
    @cibertwin5356 3 роки тому

    Thanks!!! you are doing a great job here. This is very helpful

    • @ProgramWithGio
      @ProgramWithGio  3 роки тому

      Glad to hear that, you're welcome 🙌

    • @cibertwin5356
      @cibertwin5356 3 роки тому

      @@ProgramWithGio Thanks 🤓. I'll definitely recommend your serie 💪🏼

  • @buffyaji73
    @buffyaji73 10 місяців тому

    Great work Appreciated, thanks a lot.

  • @iqorimane3575
    @iqorimane3575 Рік тому

    i'm not just learning great things , i'm reallyy ENJOOOYING

  • @johna2193
    @johna2193 Рік тому

    Thank you so much for providing these videos Geo. I am doing at leat a lesson a day. My goal is to eventually get good enough to do short term contract work. I am old and use to do a lot of Perl coding back in the day.

    • @ProgramWithGio
      @ProgramWithGio  Рік тому +1

      You're welcome my friend & thank you. Age does not matter to be honest, just be consistent & you'll get there, good luck 🤞

  • @sumitbhardwaz
    @sumitbhardwaz 2 роки тому +1

    superb lesson GIO 💙

  • @s4f4y4t9
    @s4f4y4t9 3 роки тому +2

    Most of the php tuorial on youtube are outdated,thanks for your effort

  • @wafflesexploit
    @wafflesexploit Рік тому +3

    I know you are already bombarded with comments saying how your videos are great, which they really are! Even then, I just wanna say that I love the fact that you don't have topics scattered between videos, instead you have a dedicated tutorials with all information you could ever want about a certain topic.
    I'm learning by myself PHP, and it makes taking notes so easier.
    So thank you so much for this great tutorials, and hope you continue growing and publishing top tier videos, as well!

    • @ProgramWithGio
      @ProgramWithGio  Рік тому +2

      Happy to hear that, thank you 🙌. Feel free to ask questions as you are going through the series 👍

  • @user-iz9xf8eb2p
    @user-iz9xf8eb2p 2 роки тому

    thank you so much for your efforts

  • @prajwalsiwakoti9866
    @prajwalsiwakoti9866 Рік тому

    total quality series for people having some experience in PHP. Good going GIO

  • @nielsofficeofficial9706
    @nielsofficeofficial9706 2 роки тому

    Thank you, Gio! you are really amazing ! :))

  • @KaraSuraDraw1
    @KaraSuraDraw1 Рік тому +2

    I now understand why my tutors in school hammered us on the fundamentals of programming. My fundamentals are good right now and I don't find it hard to switch to another programming language anymore. Of course, I don't know the ins and outs of that programming language, but I can build things as soon as I know the syntax of the language I am working with. Just like now, I can just go fast through your videos. Just wanted to let you know that your videos are very clear for beginners. Thank you for this series, I think I will learn when I get to your more advanced stuff about classes and such things.

    • @ProgramWithGio
      @ProgramWithGio  Рік тому

      That's awesome, thank you, I appreciate it. Yes it gets more fun later on 🙂

  • @user-zh2oz9fe4m
    @user-zh2oz9fe4m 10 місяців тому

    It's impossible to do without arrays. Thanks for the video!

  • @IsfhanAhmed
    @IsfhanAhmed 2 роки тому

    awesome teacher

  • @alnahian2003
    @alnahian2003 Рік тому

    Whoop! This was a long one 😄
    Never knew I could use something like, [...., 30 => 'value', 'other', 'another'....]

  • @David-ok9vt
    @David-ok9vt Рік тому +3

    Probably the most thorough video course on PHP ever produced. Thank you so much Gio. I do wish you hadn't cut out all of the gaps between sentences during editing though! 😂 I find watching you on .75 speed compensates and gives me just about enough time to take in the concepts and examples. Would second Dushyant's wish for a Laravel Framework series.

    • @ProgramWithGio
      @ProgramWithGio  Рік тому +2

      Thank you 💙. I was a bad editor 😁 still am but improving little by little heh

  • @raohammadraza7056
    @raohammadraza7056 2 місяці тому

    You are teaching well amazing series please create more series specially python and Java Script

  • @jailsoncarneiro4936
    @jailsoncarneiro4936 8 місяців тому

    The last tip is fkn amazing!

  • @lubnaboghara8690
    @lubnaboghara8690 Рік тому

    good explanation.....................

  • @stefanbirsan3320
    @stefanbirsan3320 3 роки тому +1

    the best!

  • @QorashyTech
    @QorashyTech Рік тому +1

    Thanks!

  • @malikhaidi434
    @malikhaidi434 Рік тому

    Gio Brother your course is well explained and it's very interesting.
    Brother, please make more courses with real-world projects like Javascript, Python, etc.
    Thank you Brother for this course . Stay blessed and Happy.
    😇

  • @ahmedmahdy6676
    @ahmedmahdy6676 2 роки тому

    Thank you!

  • @whisperscribe
    @whisperscribe 2 місяці тому

    thank you!

  • @AxxionMarketPlace-iu6ri
    @AxxionMarketPlace-iu6ri 11 місяців тому

    Thank you

  • @abdussukkur9080
    @abdussukkur9080 3 роки тому +1

    What a great teaching Style!😮 Although already I know the PHP basic staff and OOP after that I see your videos. Because in every single video I learn new things.
    I see your YT about and see that your first language was PHP and also you works with Laravel. After complete the course If you create a Laravel course really It will be very helpful.💖💖 Thanks again....

    • @ProgramWithGio
      @ProgramWithGio  3 роки тому +1

      That's great to hear, thank you. There will be more content on Laravel after this 👍

    • @abdussukkur9080
      @abdussukkur9080 3 роки тому +1

      @@ProgramWithGio Waiting for Laravel Course.

  • @lostcarpark
    @lostcarpark Рік тому

    Very useful stuff!
    One thing that can be problematic with arrays is when you want to display a value in a multi-dimension array, but you're not certain all the levels will be present, so you can end up with multiple levels of checks on all the levels of the array. If you just want to display the value if present, the ?? operator can be super handy, as it won't post a warning if any of the levels or missing.
    For example, you might want to display $user[$next]['jobs']['current']['title'] , and if you're not sure if a user has any jobs, or a current one, or if it has a title, you can end up with something like:
    echo (isset($user[$next]['jobs'] && $user[$next]['jobs']['current'] && $user[$next]['jobs']['current']['title']) ? $user[$next]['jobs']['current']['title'] : '');
    However, with the ?? operator, this can be simplified to:
    echo ($user[$next]['jobs']['current']['title'] ?? '');

    • @ProgramWithGio
      @ProgramWithGio  Рік тому

      Thank you. If you have such arrays then I would suggest a differently structured data like objects. We cover DTOs in third section so once you get to that point you'll see how DTOs can be helpful in such cases

    • @lostcarpark
      @lostcarpark Рік тому

      @@ProgramWithGio That's true, but sometimes you have to work with an existing project, and don't have the control to restructure it. I have also been enjoying the new ?-> operator for working with this sort of structure in objects.

  • @kenjohnsiosan9707
    @kenjohnsiosan9707 2 роки тому

    thank u sir.

  • @montassirben8560
    @montassirben8560 Рік тому

    thank you

  • @jessieren6476
    @jessieren6476 2 роки тому

    Many thx

  • @angus-mcritchie
    @angus-mcritchie 2 роки тому +1

    Love the videos, great pace and good clear info. I'm interested is learning why many developers use keyed arrays instead of using a StdClass object, for example at 8:57 it would make sense for me for each programming language to be an object. What am I missing as this seems common practice?

    • @ProgramWithGio
      @ProgramWithGio  2 роки тому +1

      Thank you. You could use StdClass objects for sure, if you have a defined structure then objects probably make more sense but also associative arrays are pretty common. Instead of StdClass object you could create an entity class or a DTO that would serve similar purpose. The reason I did not use or talk about objects in this lesson is because objects are covered in 2nd section of the course

  • @omerchen7948
    @omerchen7948 Рік тому

    ty

  • @dgloria
    @dgloria 2 роки тому

    Great job. Love the example at 11:00. Who is Gio?

  • @rimantasdanilevicius6754
    @rimantasdanilevicius6754 3 роки тому +2

    Great and smooth lesson about arrays! And Again I learned and heard new info which I never heard before. I like that you make points where developer should be careful, where can be problems. Lessons well explained that I wondering is it really so natural or you do your homework too? :D
    Thanks for lesson and waiting for next!

    • @ProgramWithGio
      @ProgramWithGio  3 роки тому +5

      Thank you. So my strategy for recording is that I write down what I know, main points, things to be aware of, etc. Then I do research to confirm that what I know is still valid in the current version because as you know PHP advances & introduces new things, deprecates old stuff, & even the standards change sometimes. And based on the research I make adjustments to my notes and usually I discover some things during this research phase too that I think would be beneficial for developers to know. Some things are small details but in my opinion, these small details play a big role later in programming & that applies to any programming language, not just PHP.
      In short, yea I do research & homework for sure :)

    • @rimantasdanilevicius6754
      @rimantasdanilevicius6754 3 роки тому +2

      ​@@ProgramWithGio Such comment really brings confidence to your content quality!
      I really cant wait to see what kind content you will bring then or If you will be teaching intermediate PHP stuff!

    • @ProgramWithGio
      @ProgramWithGio  3 роки тому +1

      @@rimantasdanilevicius6754 thank you very much. Yes we will be doing intermediate/advanced topics. Section 1 of course is gonna end soon and we'll begin section 2 which is all about OOP and some cool topics. Section 3 is more advanced stuff. This will be a long course, it won't be a "learn php in 3 hours" type because I want to make sure I cover important topics & in depth.

    • @rimantasdanilevicius6754
      @rimantasdanilevicius6754 3 роки тому +3

      @@ProgramWithGio Sounds you have plan, and that is really great!
      Please cover SOLID principles and help to understand how to right code more cleaner. Most examples and exercises on youtube or other channels is just basics and follows no SOLID principles, and such lessons do not train brains to think like programmer should think and does not covers intermediate or advance topics. Hoping in your future projects and lessons you will include exercises and examples which will help train brains work :D

    • @ProgramWithGio
      @ProgramWithGio  3 роки тому +1

      @@rimantasdanilevicius6754 Yup, clean & simple code is part of the course. Once we'll get towards the end of Section 2 & begin Section 3 you'll see more project-like tutorials where we'll write more code. As for SOLID, it's great but sometimes it gets misused or over-used, I'll be sure to cover that as well.

  • @simxtube
    @simxtube 7 місяців тому

    Now I won't need to watch more PHP array videos. I often faced challenges in Laravel when working with multidimensional arrays. I'm hopeful that this tutorial will resolve those issues. Thank you for the valuable knowledge ❤❤

  • @EgorDemeshko
    @EgorDemeshko 5 місяців тому

    intresting, i wonder if access to assosiative array(with key, ) in php , works as hash table?

    • @ProgramWithGio
      @ProgramWithGio  4 місяці тому

      Yes, internally I think it uses hash table mechanism

  • @veshalenramsamy1342
    @veshalenramsamy1342 8 місяців тому

    🏆legendary

  • @open-mindedlearners
    @open-mindedlearners Рік тому

    Hi Gio, I was thinking about the [ 'version' => 7.4, 'releaseDate' => 'Nov 28, 2019' ], comma at the end of this array and there is also comma that is at the end of index1(array) in python versions. Are these commas necessary and also at the end of versions enclosing these arrays

    • @ProgramWithGio
      @ProgramWithGio  Рік тому +1

      Hey, no they are not necessary its optional, so mostly its up to you & the conventions that you follow.

  • @ahmedhabeeb2499
    @ahmedhabeeb2499 3 роки тому +1

    thank you, we need to end the course real project

    • @ProgramWithGio
      @ProgramWithGio  3 роки тому +5

      Yes, we'll do real projects towards the end of the course. We are still at early stage in the course 👍

    • @ahmedhabeeb2499
      @ahmedhabeeb2499 3 роки тому +1

      @@ProgramWithGio thank you very much for your effort

    • @ProgramWithGio
      @ProgramWithGio  3 роки тому +1

      @@ahmedhabeeb2499 you're welcome 🙌

  • @Kelz_codes
    @Kelz_codes Місяць тому

    Another way of adding to an array is using "..." operator
    $a = ['a', 'b', 'c'];
    var_dump([...$a, ]);

    • @ProgramWithGio
      @ProgramWithGio  Місяць тому

      Its more like creating a new array while combining the other array elements with new, but yes

  • @WolfrupvanSen
    @WolfrupvanSen Рік тому

    pls make a video on which extensions you are using pls make some small video

  • @bibid8940
    @bibid8940 Рік тому

    4:12 made me chuckle lol

  • @faramarztayyari3734
    @faramarztayyari3734 2 роки тому +1

    hi
    why when I compare empty array with empty string or 0 , php return false ?
    Isn't it true that empty array cast to 0 and if other side be zero , result shod be true in loose compare?

    • @faramarztayyari3734
      @faramarztayyari3734 2 роки тому +1

      I found a answer for own question :)
      array is always greater then anything , because of that when compare array with anything result is false.

    • @ProgramWithGio
      @ProgramWithGio  Рік тому

      I'm sorry for the super late reply. UA-cam did not notify me about this & just came across it. Glad you figured it out 💙

  • @mikhailmcrae5924
    @mikhailmcrae5924 Рік тому

    Why use isset() function when you can get the same result putting a variable as a parameter for an if statement?

    • @ProgramWithGio
      @ProgramWithGio  Рік тому

      There are differences. Checking for variable in if statement checks for truthy value while isset checks if the variable is defined or key is set in array

  • @lovietech3885
    @lovietech3885 2 роки тому

    Is there anything like this in php as how it is in python without using loop;
    num = [4, 7, 9, 0, 2]
    print num[0:2]
    This is to print from index 0 to index 2 which the output is 4, 7, 9

  • @sheezanawaz476
    @sheezanawaz476 2 роки тому +1

    Please guide me in this situation . I wanna to store hallID as a key and hall_Capacity as a value and these keys and values we fetch from Database Table. $examination_hall = array(
    $hallID=>$capacity

    );
    print_r($examination_hall);
    // ( [1] => 10 [2] => 20 [3] => 30 ) I want output like this but output showing only [3] => 30

    • @ProgramWithGio
      @ProgramWithGio  2 роки тому

      Because you are overwriting the array every time. Do it this way $examination_hall[$hallID] = $capacity

    • @sheezanawaz476
      @sheezanawaz476 2 роки тому

      @@ProgramWithGio Thank you so much .values with keys are stored in array but I have another issue. I want to use hall_id in insert query .For example if first hall capacity are 10 then first hall_id use ten time only in this query after this it comes to second hall_id and then third hall_id according to capacity. Now all values are stored in array but still in insert query use hall_id 3 only .i write code for this plz check it $examination_hall[$hallID] = $capacity; foreach ($examination_hall as $hall) {
      $currenthall_cap=" "; / / this variable declare for store the current capacity of hall against of each hall_id
      $currenthall_cap = $hall; while ($currenthall_cap > 0 && $StudentCount > 0 ){ $schedule = "INSERT INTO exam_sched (student_id, hall_id)
      VALUES({$studentID[$studentCounter]},{$hallID})"; if(mysqli_query($conn,$schedule));

      {
      $studentCounter++;
      $currenthall_cap--; // when current hall capacity become 0 it must be go to second hall but the hall_id remain same.
      $StudentCount--;

      } } }

    • @ProgramWithGio
      @ProgramWithGio  2 роки тому

      @@sheezanawaz476 sorry but it's hard to understand what the issue is. Ping me on Twitter and send me a screenshot of formatted code with a little more explanation

    • @sheezanawaz476
      @sheezanawaz476 2 роки тому

      @@ProgramWithGio but I have no tweeter account.

  • @itzcallmepro4963
    @itzcallmepro4963 2 роки тому

    thanks for the effort . source code would be better

    • @ProgramWithGio
      @ProgramWithGio  2 роки тому

      You're welcome. Later in the course I provide source code for certain videos. Didn't think source for this video was important since it's mainly overview

  • @magedghabour2466
    @magedghabour2466 Рік тому

    Why null cast to empty string Not 0 . in Index three cast 1.8 to integer and in Index four cast to string why ?! 11.03

    • @ProgramWithGio
      @ProgramWithGio  Рік тому +1

      That's just how it gets casted when used as array key. You can read more about it in the docs here: www.php.net/manual/en/language.types.array.php
      `Strings containing valid decimal ints, unless the number is preceded by a + sign, will be cast to the int type. E.g. the key "8" will actually be stored under 8. On the other hand "08" will not be cast, as it isn't a valid decimal integer.
      Floats are also cast to ints, which means that the fractional part will be truncated. E.g. the key 8.7 will actually be stored under 8.
      Bools are cast to ints, too, i.e. the key true will actually be stored under 1 and the key false under 0.
      Null will be cast to the empty string, i.e. the key null will actually be stored under "".`

  • @WaliaIbex
    @WaliaIbex 4 місяці тому

    The Ethiopian God bless you 🎉🎉🎉

  • @pravin1074
    @pravin1074 2 роки тому

    Array keys why string '1' replace intger 1.

    • @ProgramWithGio
      @ProgramWithGio  2 роки тому

      Where did you see '1'? I used integers for keys. In one part I used '1' to show an example that '1', 1 and true would be same keys and overwrite.

    • @pravin1074
      @pravin1074 2 роки тому

      @@ProgramWithGio in 10:22sec foo baz example you using string and integer key?

    • @ProgramWithGio
      @ProgramWithGio  2 роки тому

      @@pravin1074 yea that's to demonstrate that it overwrites. I also use float right after 1.8 and as you see the result is that last one overwrites.

    • @ProgramWithGio
      @ProgramWithGio  2 роки тому

      I understand your question now. The reason string overwrites integer is because it comes after, same with float 1.8 value overwrites previous ones because all of those get cast into 1

  • @Laracoding
    @Laracoding Рік тому

    Is array a data structure or a data type ??

  • @skratchyy
    @skratchyy 2 місяці тому

    გიო ლარაველის კურსი როდის დაიდება :D

    • @ProgramWithGio
      @ProgramWithGio  2 місяці тому

      ზაფხულის ბოლოსკენ ალბათ. დავიწყე მუშაობა კურსზე

    • @skratchyy
      @skratchyy 2 місяці тому

      მადობა

  • @ivandosev9779
    @ivandosev9779 Рік тому

    $arr = [PHP_INT_MAX => 1, 2, 3];
    Warning: Cannot add element to the array as the next element is already occupied

    • @ProgramWithGio
      @ProgramWithGio  Рік тому

      I would assume because it can't hold anymore values? I'm not sure to be honest, maybe something has to do with the way arrays are implemented in PHP, they are essentially hash tables. This article might help: www.npopov.com/2012/03/28/Understanding-PHPs-internal-array-implementation.html

  • @ilya_123__
    @ilya_123__ 9 місяців тому

    thank you