1. Merging arrays
The Array_merge () function merges the arrays together to return an array of unions. The resulting array starts with the first input array parameter, forcing it sequentially in the order in which the array parameters appear later.
Example code:
<?PHP$arr=Array("A", "B", "C"); $BRR=Array("1", "2", "3"); $CRR=Array_merge($arr,$BRR); Print_r($CRR); /*==================== PrintingResults===========================*/
Array([0] = A [1] = B [2] = = C [3] = 1 [4] = 2 [5] = 3)
?>
2. Append array
The array_merge_recursive () function is the same as Array_merge () and can combine two or more numbers together to form an array of unions. The difference between the two is that when a key in an input array is already in the result array, the function takes a different approach. Array_merge () overrides the previously existing key/value pair, replacing it with the key/value pair in the current input array, and array_merge_recursive () merges two values together to form a new array with the original key as the array name. There is also the form of an array merge, which is a recursive append array.
Example code:
<?PHP$arr=Array("A" =>1, "B" =>2, "C" =>3); $BRR=Array("A" =>4, "B" =>5, "C" =>6); $CRR=array_merge_recursive($arr,$BRR); Print_r($CRR); /*==================== Printing Results ===========================*/Array([A] = =Array([0]=>1,[1]=>4),[B]=Array([0]=>2,[1]=>5),[C]=Array([0]=>3,[1]=>6), ) ?>
3. Connect an array
The Array_combine () function gets a new array that consists of a set of committed keys and corresponding values.
Example code:
<? php $arr = array ("A", "B", "C" ); $brr = array ("1", "2", "3" ); $CRR = array_combine ( $arr , $BRR ); print_r ( $CRR ); /* */ array (' A ' = > 1, ' B = 2, ' C '
4. Split fraction Group Array_slice ()
The Array_slice () function returns a portion of the array, starting with the key offset and ending at the offset+length position.
Example code:
<? PHP $ARR Array ("A", "B", "C", "D", "E", "F", "L"); $BRR Array_slice ($Arr, 3); Print_r ($Brr); /* ==================== Printing Results =========================== */ Array ([0] = ' D ', [1] = ' E ', [2] = ' F ', [3] = = ' L'?>
5. Array difference set Array_diff ()
The function Array_diff () returns a value that appears in the first array but not in the other input array. This function is opposite to Array_intersect ().
Example code:
<? PHP $arr = array ("A", "B", "C" Span style= "color: #000000;" >); $brr = array ("A", "2", "C" ); $CRR = array_diff ( $arr , $BRR ); print_r ( $CRR ); /* */ array ([0]= > ' A ' ) ?
PHP Data Processing-merge, split, append, Redo