1 / 4

Understanding PHP Arrays: Basic Concepts, Unordered, and Associative Arrays

This guide explores the fundamentals of arrays in PHP, including how array keys work and the differences between indexed and associative arrays. We begin with basic array creation, noting that if no key is set, PHP auto-increments to assign keys starting from 0. We also look at unordered arrays, where specific keys can be assigned at will, followed by associative arrays that allow for named keys. Examples provided demonstrate how to access and manipulate array elements effectively, highlighting the structure and behavior of each array type.

Download Presentation

Understanding PHP Arrays: Basic Concepts, Unordered, and Associative Arrays

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. PHP5 Array concepts

  2. Basic Array • If you do not set the key when you create an array the initial value is 0 and then it auto increments $arr[] = “First index”; $arr[] = “Second index”; print($arr[1]); // is “Second index” print($arr[0]); // is “First index”

  3. Array Unordered • You can specifically give an array key and not do this in a specific order $arr[12] = “First index”; $arr[9] = “Second index”; print($arr[9]); // is “Second index” print($arr[12]); // is “First index”

  4. Associative Array • You can specifically give an array key a name $arr[‘name_first’] = “Ray”; $arr[‘name_last’] = “Gubala”; print($arr[‘name_first’]); // is “Gubala” print($arr[‘name_last’]); // is “Ray”

More Related