PHP array_unshift() Function6 Jan 2025 | 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. SyntaxParameters
Return ValuesThe array_unshift( ) function returns the new number of elements in the array. Important note:All numerical array keys will be modified to start counting from zero while literal keys won't be changed. Example 1Output: 1 2 3 java t point Example 2Output: Array ( [0] =>sachin [1] =>sehwag [2] =>harbhajan [3] =>virat [4] =>rohit [5] =>pandeya ) Example 3Output: Array ( [0] =>leneovo [1] =>acer [2] => dell [3] =>hp) Example 4Output: Array ( [0] =>pune [1] =>kolkata [2] =>bangalore [3] =>delhi ) Next TopicPhp-array-usort-function |
It is an inbuilt function in PHP. The array_column() function is used to return the values from a single column in the input array. This function is introduced in PHP 5.5. Syntax array_column(array,column_key,index_key); Parameter Description Is compulsory array Specifies the multi-dimensional array to use compulsory Column_key This parameter may be an integer or a string...
2 min read
The array_udiff_assoc( ) function is an inbuilt function of PHP. The array_udiff_assoc( ) function use a built-in function to compare the keys and values of two or more arrays, and returns the differences. This function was introduced in PHP 5.0. Syntax array array_udiff_assoc ( array $array1 ,...
1 min read
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_diff() function compares two or more arrays and returns an array with the keys and values from the first array, only if the value is not present in any of the other arrays. This function was introduced in PHP 4.0. Syntax array_diff(array1,array2,array3...); Parameter Description Is compulsory array1 The array to compare...
2 min read
The array_arsort( ) function is an inbuilt function of PHP. The array_arsort( ) function is used to sort an array in reverse order and the function maintains index association. This function was introduced in 4.0. Syntax bool arsort ( array &$array [, int $sort_flags = SORT_REGULAR ]...
1 min read
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 shuffle() Function The PHP shuffle( ) function is used to randomize the order of the elements in the array. The function assigns new keys to the elements in an array. This function introduced in PHP 4.0. Syntax bool shuffle ( array &$array ); Parameter Parameter Description Is compulsory array Specifies the array to...
1 min read
The array_pop() function is inbuilt function of PHP. The array_pop() function is used to remove the last element of an array. For an empty array, this function returns NULL. This function was introduced in PHP 4.0. Syntax mixed array_pop ( array &$array ); Parameters Parameter Description Required/Optional array Specifies an array. compulsory Return Type The array_pop()...
1 min read
PHP sort() Function The PHP sort( ) function is used to sort the array elements in ascending order. This function was introduced in PHP 4.0. Syntax bool sort ( array &$array [, int $sort_flags = SORT_REGULAR ] ); Parameter Parameter Description Is compulsory array Specifies the array to be sorted. compulsory Sort flags Sorting behavior. Possible type : SORT_REGULAR...
1 min read
The array_udiff( ) function is an inbuilt function of PHP. The array_udiff( ) function is used to compute the difference of given arrays by using a callback function for data comparison. This function was introduced in PHP 5.1.0. Syntax array array_udiff ( array $array1 , array $array2...
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