How to solve a php array

Source: Internet
Author: User
The usage of solving a php array shows a code written by someone else, similar to this:
$a = array();$a['key'] = $a['key'] + 1;var_dump($a);

As you can see, 1 in the code changes to the value of array ..
This .. I have never used it like this ..


Reply to discussion (solution)

Accumulate, similar to a + = 1;

Is an array...

Equivalent to $ a ['key'] = null + 1;

Equivalent to $ a ['key'] = null + 1;



Don't understand ..


Equivalent to $ a ['key'] = null + 1;



Don't understand ..


Not understand

Equivalent to $ a ['key'] = null + 1; positive solution

$ A = array ();
$ A ['key'] = $ a ['key'] + 1; // at this time, $ a ['key'] does not exist, use isset ($ a ['key']) to return false, so $ a ['key'] = null
$ A ['key'] + 1 is equivalent to null + 1 because php will automatically convert null to 0 for arithmetic operations, so it is 0 + 1, last $ a ['key'] = 1

Var_dump ($ );

It is best not to write like this. php is a weak-type statement. if you want to improve the execution efficiency, you 'd better declare the type in advance instead of letting the system identify it.



Equivalent to $ a ['key'] = null + 1;



Don't understand ..


Not understand


Oh .. I understand. I understood it wrong.

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.