![]() This allows you to also reference the array item by its string key. 'subheading' => 'How to get an array size', 'heading' => 'PHP Array Length Tutorial', ![]() echo $post_data In PHP, Array keys start at 0įor even more control, arrays also allow you to define your own array keys, using a string. So instead of needing to recall the single variables, you could reference a single array item by its numeric key. $post_data = array(Įach item in that array can be referenced by its numeric key. You can still store the individual pieces of data but using a single variable. That's all well and good, but what if you need to store more data, and quickly recall any of those items elsewhere in your code? That's where an array comes in handy. ![]() $subheading = 'How to get an array size' However, if you wanted to store a few more pieces of separate data, you might consider using a couple of string variables. An array in PHP is a variable type that allows you to store more than one piece of data.įor example, if you were storing a simple string, you would use a PHP string type: $heading = 'PHP Array Length Tutorial' What is an Array in PHP?īefore we dive into getting an array size, we need to make sure we understand what an array is. ![]() If you already know what arrays are, you can jump straight ahead to the How to get an Array size? section. In this article I'll give you a quick overview of how arrays work, and then I'll dive into how to get the size of PHP arrays. And knowing how to quickly determine the size of an array is a useful skill. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |