PHP array_splice() Function6 Jan 2025 | 2 min read The array_splice() function is an extended version of array_slice() function. The array_splice() function removes selected elements from an array and replaces it with new elements. This function was introduced in PHP 4. SyntaxParameters
Return ValuesThe array_splice( ) function returns an array which consists of the extracted elements. Important note:If offset and length are such that nothing is removed, then the elements from the replacement array are inserted in the place specified by the offset. The keys in the replaced array are not preserved. Example 1Output: Array ( [0] =>AbhinavBindra [1] =>Sushilkumar ) Example 2Output: Array ( [0] =>AbhinavBindra [1] => Mary kom ) Example 3Output: Array ( [0] =>AbhinavBindra [1] =>Vijendersingh ) Example 4Output: Array ( [a] => apple [b] => banana ) Next TopicPhp-array-sum-function |
The array_walk( ) function is an inbuilt function of PHP. It is used to apply a user supplied function to every element of an array. This function was introduced in 4.0. Syntax bool array_walk ( array &$array , callable $callback [, mixed $userdata = NULL ] ); Parameters Parameter Description Is...
1 min read
The array_map( ) is an built-in function in PHP. The array_map( ) function sends each value of an array to a user-defined function, and returns an array with new values given by the user-defined function. This function was introduced in 4.0.6. Syntax array array_map ( callable $callback...
1 min read
The array_uintersect_assoc( ) function is an inbuilt function of PHP. The array_uintesect_assoc() function compares two or more arrays, and then returns an array containing the elements from the first array. This function was introduced in PHP 5.0. Syntax array array_uintersect_assoc ( array $array1 , array $array2 [,...
1 min read
The array_search() function is an inbuilt function of PHP. It is used to search the array against the given value. The function returns the first corresponding key if successful. This function was introduced in PHP 4.0.5. Syntax mixed array_search ( mixed $needle , array $haystack [, bool...
1 min read
PHP array_unique( ) Function The array_unique( ) function is an inbuilt function of PHP and it is used to remove duplicate values from an array. This function was introduced in 4.0.1 Syntax array array_unique ( array $array [, int $sort_flags = SORT_STRING ] ); Parameters Parameter Description Is compulsory array1 The input array. compulsory sort_flags The optional...
1 min read
The array_unshift( ) function is an inbuilt function of PHP. It is used to add one or more elements to the beginning of an array. This function was introduced in PHP 4.0. Syntax int array_unshift ( array &$array [, mixed $... ] ); Parameters Parameter Description Is compulsory array The input array. compulsory List of...
1 min read
This function is used to flip the array with the keys and values. It takes one parameter that is an array. The returned array will contain the flipped elements. The values will be the keys, and the keys will be the values. This function was...
1 min read
The array_fill_keys( ) function is a built-in function in PHP. It is used to create a new array filled with the given keys and value provided as an array to the function. It was introduced in PHP version 5.2. Syntax array array_fill_keys ( array $keys , mixed...
1 min read
The array_values( ) function is an inbuilt function of PHP. It is used to get an array of values from another array that may contain key-value pairs. This function was introduced in PHP 4.0. Syntax array array_values ( array $array ); Parameters Parameter Description Is compulsory array Specifying an array. compulsory Return Values The array_values( )...
1 min read
The array_intersect_uassoc( ) function is an inbuilt function in PHP. The array_intersect_uassoc( ) function is used to compare key and values of two or more arrays by using a user-defined comparison function and return the matches. It returns an array containing all the values of...
2 min read
We request you to subscribe our newsletter for upcoming updates.
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India