Php array summation array intersection content replacement and other operations. This tutorial focuses on intermediate data operations, replacing array elements with intersection content, and searching for array content. This tutorial focuses on intermediate data operations and array elements. this tutorial describes intermediate data operations, replacing array elements with intersection content, and searching for array content.
This tutorial focuses on intermediate data operations, replacing array elements with intersection content, and searching for array content.
*/
$ Input = array ("red", "green", "blue", "yellow"); // defines the original array
Array_splice ($ input, 2); // perform the removal operation
Print_r ($ input); // output the processed result
$ Input = array ("red", "green", "blue", "yellow"); // defines the original array
Array_splice ($ input, 1,-1); // execute the removal operation and specify the length.
Print_r ($ input); // output the processed result
$ Input = array ("red", "green", "blue", "yellow"); // defines the original array
Array_splice ($ input, 1, count ($ input), "orange"); // you can perform the removal operation and specify the length and content.
Print_r ($ input); // output the processed result
$ Input = array ("red", "green", "blue", "yellow"); // defines the original array
Array_splice ($ input,-, array ("black", "maroon"); // replace the content with an array
Print_r ($ input); // output the processed result
$ Input = array ("red", "green", "blue", "yellow"); // defines the original array
Array_splice ($ input, 3, 0, "purple ");
Print_r ($ input); // output the processed result
//
$ Sweet = array ('a' => 'apple', 'B' => 'bana'); // define the original array
$ Fruits = array ('sweet '=> $ sweet, 'sour' => 'limon'); // define another array
Function test_print ($ item, $ key) // user-defined function
{
Echo "$ key holds $ itemn"; // Two parameters are output.
}
Array_pai_recursive ($ fruits, 'Test _ print'); // recursively calls a user-defined function for members of the logarithm Group
// Sum
$ A = array (2, 4, 6, 8); // defines the original array
Echo "sum (a) =". array_sum ($ a). "n"; // sum
$ B = array ("a" => 1.2, "B" => 2.3, "c" => 3.4); // define the original array
Echo "sum (B) =". array_sum ($ B). "n"; // sum
// Array intersection
Function strcasecmp ($ key1, $ key2)
{
If ($ key1 = $ key2) // if the two parameters are equal
Return 0; // return 0
Else if ($ key1> $ key2) // if the first one is greater than the last one
Return 1; // return 1
Else // if the first one is smaller than the last one
Return-1; // return-1
}
$ A1 = array ("a" => "green", "B" => "brown", "c" => "blue", "red "); // define array 1
$ A2 = array ("a" => "green", "B" => "brown", "yellow", "red"); // define array 2
Print_r (array_uintersect_uassoc ($ a1, $ a2, "strcasecmp", "function"); // calculates the intersection of two arrays
// Array intersection
$ A = array ("a" => "green", "B" => "brown", "c" => "blue", "red "); // define array 1
$ B = array ("a" => "green", "B" => "brown", "yellow", "red"); // define array 2
$ Result = array_uintersect ($ a, $ B, "strcasecmp"); // calculates the array intersection.
Print_r ($ result );
Replace and search for the array content. This tutorial focuses on intermediate operations on data, seeking array elements...