: This article mainly introduces the Subtotal of PHP Array Operations. if you are interested in the PHP Tutorial, please refer to it. Arrays in PHP are the most basic and most commonly used operations. PHP has many built-in convenient functions for us to use. However, the translation of official documents is sometimes not so easy to understand, in addition, some functions do not need to be confused during the time interval. Good memory is not as bad as a pen, I will slowly record some of the commonly used functions here, and make a demo to understand how to use them.
1. array merging
Array merging is a simple thing, but the simpler the thing, the easier it is to forget, especially when it is rarely used ....
"; $ A = [, 3]; $ B = [, 6]; // 1. PHP array merging function $ c = array_merge ($ a, $ B); var_dump ($ c); // 2. the directly added array is sequentially overwritten by the key. the subsequent key overwrites the previous key value $ c = $ a + $ B; var_dump ($ c); // 3. $ c = $ B + $ a; var_dump ($ c); // 4. to understand this, array_push ($ a, $ B); var_dump ($ );
Result:
1.array(6) { [0]=> int(1) [1]=> int(2) [2]=> int(3) [3]=> int(4) [4]=> int(5) [5]=> int(6)}2.array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)}3.array(3) { [0]=> int(4) [1]=> int(5) [2]=> int(6)}4.array(4) { [0]=> int(1) [1]=> int(2) [2]=> int(3) [3]=> array(3) { [0]=> int(4) [1]=> int(5) [2]=> int(6) }}
The above introduces the PHP array operation subtotal, including the content, hope to be helpful to friends who are interested in the PHP Tutorial.