PHP Learning Notes (a) array

Source: Internet
Author: User

  methods for initializing arrays: Unified initialization or initialization by item.

  Ways to iterate through an array:

1. For loop

2. Do ... While statement

3. While statement

4. foreach

foreach ($arras$key=$val)    {        echo$key. " =". $val. " <br/> ";    }

The key value in an array can be an integer or a string.

An array can store any data type.

Understanding content: Array Operators.

 Array sorting issues:

  Internal sorting:

1. Bubble sort

2. Select the Sorting method

3. Insert Sort method

4. Fast sorting method

  External sort:

Questions about function Parameters:

  When the formal parameter takes the address: Indicates that the address is passed, and the address in the original array passes through, changing the original value.

When the parameter does not take address: The default pass is a value pass, not an address pass, which is a new array pass, and does not alter the value of the original array.

Other knowledge:

Common functions:

1. Count

Count ($arr);  // gets the length of the array

2, Is_array: Determine whether the array.

3. Print_r: Displays easy-to-understand information about a variable. If a string,integer , or floatis given, the variable value itself is printed. If an array is given , the keys and elements are displayed in a certain format. Object is similar to an array.

4. Var_dump: Returns the type and value of an expression.

5, Explode: Use one string to split another string.

6. Round: Rounding the specified number of digits for floating-point numbers.

7, unset: Destroy an element, you can also destroy a variable.

When a variable is destroyed in an array, the array is not automatically re-assembled, and the data corresponding to that key value in the array is undefined

8.How to turn off notice level tips in PHP:

1.php.ini file modified to: error_reporting = E_all & ~e_notice

2. Add code to the page where you want to suppress error prompts: error_reporting (e_all ^ e_notice);

PHP Learning Notes (a) array

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.