//
$ Array = array (, =>, 3 => 13); // create an array
Print_r ($ array); // outputs the array content
//
$ A = array ('green', 'red', 'yellow'); // defines the first array.
$ B = array ('avcado', 'apple', 'bana'); // defines the second array.
$ C = array_combine ($ a, $ B); // use the first two array values as the keys and values of the new array.
Print_r ($ c); // outputs the newly created array
//
Foreach (range () as $ number) // returns array 0-12
{
Echo $ number .",";
}
Echo "<p> ";
Foreach (range (0,100, 10) as $ number) // returns the array, 20 ...... 100
{
Echo $ number .",";
}
Echo "<p> ";
Foreach (range ('A', 'I') as $ letter)
{
Echo $ letter .",";
}
Echo "<p> ";
Foreach (range ('C', 'A') as $ letter) // returns the array c, B,
{
Echo $ letter .",";
}
//
$ Input_array = array ('A', 'B', 'C', 'D', 'E'); // defines the initial array
Print_r (array_chunk ($ input_array, 2); // splits the array without retaining the original array key name
Print_r (array_chunk ($ input_array, 2, true); // splits the array and retains the original array key name
//
$ Array = array (1, "hello", 1, "php", "hello"); // defines an array
Print_r (array_count_values ($ array); // assign the number of occurrences of the original array element to the new array and display it
//
$ Array1 = array ("a" => "green", "B" => "brown", "c" => "blue", "red "); // define array 1
$ Array2 = array ("a" => "green", "yellow", "red"); // defines array 2
$ Result = array_diff_assoc ($ array1, $ array2); // assign the difference set of the two arrays to the array
Print_r ($ result); // output the content of the difference set
//
$ Array1 = array ('blue' => 1, 'Red' => 2, 'green' => 3); // define array 1
$ Array2 = array ('green' => 4, 'blue' => 5, 'yellow' => 6); // define array 2
$ Result = var_dump (array_diff_key ($ array1, $ array2); // calculate the difference set of key names
Print_r ($ result );
//
// Define the callback function
Function key_compare_func ($ a, $ B)
{
If ($ a = $ B)
{
Return 0; // if the two parameters are equal, return 0
}
Return ($ a> $ B )? 1:-1; // if $ a> $ B returns 1, less than-1
}
// Define two arrays respectively
$ Array1 = array ("a" => "green", "B" => "brown", "c" => "blue", "red ");
$ Array2 = array ("a" => "green", "yellow", "red ");
// Use the callback function for index check to calculate the difference set of the array
$ Result = array_diff_uassoc ($ array1, $ array2, "key_compare_func ");
Print_r ($ result );