Detailed php Array assignment method, detailed coefficient group Assignment _php tutorial

Source: Internet
Author: User

Detailed php array assignment method, detail coefficient group assignment value


PHP array is still more commonly used, so I studied the PHP array assignment, here to take out and share with you, hope to be useful to everyone.

An array is a set of variables that are stored in the computer's memory, which can be of different types, including integers, booleans, strings, and so on. It can be said that the array is a small database in memory, it provides us with a quick way to access the data-can save the IO or the frequent access of the database to improve some performance, so about the array of some operations are also many.
How to create an array in PHP, you can use the following methods:

To create an array of methods:

Results: a b c D

Method Two:

<?php $http =array ("www", "helpphp", "cn");  Print ($http [0]. ".". $http [1]. ".". $http [2]);  

Knowledge Description:

1. As we can see from the previous example, in PHP the array defaults from subscript (index) to the position of the variable in the array, that is, we can access the array we created using the name of the $ variable [index].

2. We use the array () language structure to create the data, which, if no subscript is explicitly specified, increments the index by default from 0 onwards. The array we created has been saved in memory, but after the data is used, we need to clean it up to ensure a memory leak.

How do I assign a value to a PHP array? As follows:

Using the above method, I have created an empty array for the variable using the array language structure, and in the following statement we will assign a value to $my_array, in a previous section, we know that the array subscript (index), starting from 0 automatically increment, which means the following statement will output helpphp.
Print $My _array[1];
If you want to output $my_array all at once, you can use Print_r ($My _array). How to destroy an array or an array of elements to complete the task above, as long as the unset () function is used, it can delete an entire array or an element of an array, as follows:
Unset ($My _array[0];
unset ($My _array);
It is important to note that after you delete an array element, the index value retains its original position and does not readjust the index, you only need to be able to find this phenomenon after the deletion. Use Var_dump () to see more detail in the array, as follows:
Var_dump ($My _array);

The above is to teach you the PHP array assignment method, I hope that everyone's learning has inspired.

http://www.bkjia.com/PHPjc/1068819.html www.bkjia.com true http://www.bkjia.com/PHPjc/1068819.html techarticle detailed php Array assignment method, detailed coefficient group assignment php array or more commonly used, so I studied the PHP array assignment, here to take out and share with you, I hope you have ...

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.