PHP array_pad() Function6 Jan 2025 | 1 min read The array_pad() function is a built-in function of PHP. The array_pad() function inserts a specified number of elements, with a specified value, to an array. This function was introduced in PHP 4.0. SyntaxParameters
Return TypeThe array_pad() function returns an array with new elements. Important note: This function will not delete any elements if the size parameter is less than the size of the original array.Example 1Output: Array ( [0] => database [1] => database [2] => database [3] => compiler [4] => computing ) Example 2Output: Array ( [0] => 1 [1] => 11 [2] => 10 [3] => 12 [4] => 100 [5] => 100 ) Example 3Output: Array ( [a] => apple [b] => ball [c] => cat [0] =>javatpoint [1] =>javatpoint [2] =>javatpoint ) Example 4Output: Array ( [size] => exact [number] => 100 [color] =>green [0] =>javatpoint [1] =>javatpoint ) Next TopicPhp-array-pop-function |
The array_combine() function is an inbuilt function in PHP. This function is introduced in PHP 5. It is used to create an array by using one array for keys and another for its values. Syntax array_combine(array_keys,array_values); Parameter Description Is compulsory array_keys The keys of the array to be used compulsory array_values The values of the...
1 min read
PHP pos() Function The PHP pos( ) function is used to fetch the value of the current element in an array. The PHP pos( ) function is an alias of current( ) function. This function was introduced in PHP 4.0. Syntax pos($array); Parameter Parameter Description Is compulsory array Specifies the array to use. compulsory Returns The pos(...
1 min read
PHP usort( ) Function The PHP usort( ) function is used to sort an array by its value using a user-supplied comparison function. If the array you wish to sort needs to be sorted by some non-trivial criteria, you should use this function. This function was...
2 min read
The array_shift() function is an inbuilt function of PHP. The array_shift( ) function is used to remove the first element from an array, and returns the value of the removed element. This function was introduced in PHP 4.0. Syntax mixed array_shift ( array &$array ); Parameter Parameter Description Is compulsory array name The...
1 min read
PHP array_change_key_case() Function It is an inbuilt function of PHP. The array_change_key_case() function returns an array with all arrays keys in lower case or upper case. Syntax array_change_key_case(array,case); Parameter Description Is compulsory array Specifies the array to use compulsory case Case to use(Upper or Lower) optional Important Note: If the second parameter is avoided then by default the...
1 min read
The count( ) function is an inbuilt function of PHP, and it is used to count the elements of an array or the properties of an object. This function was introduced in PHP 4.0. Syntax int count ( mixed $array_or_countable [, int $mode = COUNT_NORMAL ] ); Parameters Parameter Description Is...
1 min read
The array_intersect( ) function is used to Computes the intersection of arrays. It compares two or more arrays and returns an array containing all the values of the first array that are present in other arrays. In this operation, keys are preserved. This function was...
1 min read
The array_multisort() is an built-in function in PHP. This function is used to sort multiple arrays at once or a multi-dimensional array with each dimension. This function was introduced in PHP 4.0. Syntax bool array_multisort ( array &$array1 [, mixed $array1_sort_order = SORT_ASC [, mixed$array1_sort_flags = SORT_REGULAR...
2 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
PHP extract() Function The extract( ) function is an inbuilt function of PHP, and it is used to import variables into the local symbol table from an array. This function was introduced in 4.0. Syntax int extract ( array &$array [, int $flags = EXTR_OVERWRITE [, string $prefix...
1 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