Theme OL

Your current location is: home page  >  Development Notes >Body

Development Notes

Detailed explanation of key conversion method in php array

Theme ol 2020-04-07 Development Notes one thousand four hundred and sixty-five
Php arrays are important data storage structures, and the use of php arrays is very flexible. Therefore, the understanding of arrays is also very important. In particular, understand the default conversion method of array keys. 1、 Acceptable types of key and value in php array 1. Key can only be integer

Php arrays are important data storage structures, and the use of php arrays is very flexible. Therefore, the understanding of arrays is also very important. In particular, understand the default conversion method of array keys.

 1.png

1、 Acceptable types of key and value in php array

1. The key can only be an integer or a string. If it is of other types, data type conversion will be performed.

2. Value can be any type.

2、 Type conversion of array key

The key will have the following cast:

1. Integer string will be converted to integer. A string containing a valid integer value is converted to an integer. For example, the key name "8" will actually be saved as 8. However, "08" will not be cast because it is not a legal decimal value.

2. Convert floating point number to integer. Floating point numbers are also converted to integer, meaning that their decimal parts are rounded off. For example, the key 8.7 will actually be saved as 8.

3. Boolean values will also be converted to integer types. That is, the key name true will be saved as 1 and the key name false will be saved as 0.

4. Null will be converted to an empty string, that is, null key name will actually be stored as "".

5. Arrays and objects cannot be used as key names. Otherwise, an error will be reported.

If multiple cells in the array definition use the same key name, only the last one is used, and the previous ones are overwritten.

Comment

Comment List

  • This article hasn't received any comments yet. Hurry to grab the sofa~

Subject description

An optimized version of this topic has been released, with a price of ¥ 58. Contact the webmaster qq five hundred and seventy million eight hundred and twenty-seven thousand seven hundred and twenty-nine Scan the code and pay for it. The difference between the free version and the free version is:

1. The copyright has been deleted, and the code can be edited freely without encryption.

2. Add article list thumbnail function, article SEO customization, and category SEO customization function.

3. The mobile terminal can upload an independent logo image and no longer call the website name.

4. The "three" shaped open button and "X" shaped close button of the navigation menu on the mobile end have been beautified.

5. The QR code of the footer will not be displayed if it is not uploaded, and no blank space will be left.

6. The QR code at the copyright of the article can be uploaded separately. If there is no QR code, it will not be displayed, and a picture that cannot be opened will not be displayed.

7. All the text in the copyright of the article can be customized, and there is no need to modify it in the code.

8. Optimized source code, more in line with SEO standards!

9. More advertising space, home page, article list page and article page have their own advertising space!

Note: This demo site is an optimized version, not a free version. However, whether it is an optimized version or a free version, their web page styles are similar, with only a few differences!