- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 35502 Articles for Programming
151 Views
The pos() function is the alias of current() function in PHP. It returns the current element of the array.Syntaxpos(arr)Parametersarr − The specified array. Required.ReturnThe pos() function returns the value of the current element in an array.ExampleThe following is an example − Live DemoOutputThe following is the output −oneExampleLet us see another example − Live DemoOutputThe following is the output −one two two
36 Views
The natsort() function sorts an array using a "natural order" algorithm.Syntaxnatsort(arr)Parametersarr − The array to sortReturnThe natsort() function returns TRUE on success, or FALSE on failure.ExampleThe following is an example − Live DemoOutputThe following is the output −Array ( [2] => Rank3 [4] => Rank7 [3] => rank1 [1] => rank2 [5] => rank4 [0] => rank10 )
30 Views
The list() function assigns variables as if they were an array. It returns the assigned array.Syntaxlist(variable1, variable2, variable 3, ...)Parametersvariable1 − the first variablevariable2 − more variablesvariable3 − more variablesReturnThe list() function returns the assigned array.ExampleThe following is an example − Live DemoOutputThe following is the output −Selected candidates: David and Jack.
39 Views
The krsort() method sorts an array by key in reverse order. It returns TRUE on success or FALSE on failure.Syntaxksort(arr, flag)Parametersarr − The array to sort.flag −0 = SORT_REGULAR - Default. Compare items normally. Do not change types.1 = SORT_NUMERIC - Compare items numerically2 = SORT_STRING - Compare items as strings3 = SORT_LOCALE_STRING - Compare items as strings, based on current locale4 = SORT_NATURAL - Compare items as strings using natural ordering.ReturnThe krsort() function returns TRUE on success or FALSE on failure.ExampleThe following is an example − Live DemoOutputThe following is the output −r = mouse q = pendrive p = ... Read More
136 Views
The in_array() function checks if a specified value exists in an array.Syntaxin_array(find, arr, type)Parametersfind − The value to be searchedarr − The array to searchtype − The mode in which the search is to be performed. If the parameter is set to TRUE, then it looks for for the search string and specific type in the array.ReturnThe in_array() function returns TRUE if the value is found in the array, or FALSE otherwise.ExampleThe following is an example − Live DemoOutputThe following is the output −Match!ExampleLet us see another example − Live DemoOutputThe following is the output −Match!Read More
180 Views
The end() function sets the internal pointer of an array to its last elementSyntaxend(arr)Parametersarr − The specified arrayReturnThe end() function returns the value of the last element in the array, on success. It returns FALSE, if the array is empty.ExampleThe following is an example − Live DemoOutputThe following is the output −solarisExampleLet us see another example − Live DemoOutputThe following is the output −one two two six six
104 Views
The current() function returns the current element in an array.Syntaxcurrent(arr)Parametersarr − The specified array. Required.ReturnThe current() function returns the value of the current element in an array.ExampleThe following is an example − Live DemoOutputThe following is the output −oneExampleLet us see another example − Live DemoOutputThe following is the output −one two two
136 Views
The compact() function creates an array containing variables and their values.. It returns an array with all the variables added to itSyntaxcompact(variable1, variable2)Parametersvariable1 − Can be a string with the variable name, or an array of variables. Required.variable2 − Can be a string with the variable name, or an array of variables. Optional.ReturnThe compact() function returns an array with all the variables added to it.ExampleThe following is an example − Live DemoOutputThe following is the output −Array ( [ELE] => Electronics [ACC] => Accessories )ExampleLet us see another example − Live DemoOutputThe following is the output −Array ( [name => Tom [subject] ... Read More
123 Views
The arsort() function sorts an array in reverse order and maintain index association.Syntaxarsort(arr, compare)Parametersarr − The specified array.compare − Specifies how to compare the array elements/items. Possible values −SORT_STRING - Compare items as stringsSORT_REGULAR - Compare items without changing typesSORT_NUMERIC - Compare items numericallySORT_LOCALE_STRING - Compare items as strings, based on current local.SORT_NATURAL - Compare items as strings using natural orderingReturnThe arsort() function returns TRUE on success and FALSE on failure.ExampleThe following is an example − Live DemoOutputThe following is the output −Key=Bangladesh : Value=9 Key=India : Value=5 Key=Australia : Value=2Read More
95 Views
The array_walk() method applies a user-defined function to every member of an array. It returns TRUE on success and FALSE on failure.Syntaxarray_walk(arr, custom_func, parameter)Parametersarr − The specified array. Required.custom_func − The user defined function. Required.parameter − The parameter to be set for the custom function. Optional.ReturnThe array_walk() function returns TRUE on success and FALSE on failure.ExampleThe following is an example − Live DemoOutputThe following is the output −p id : Student Tom q id : Student Jack r id : Student Amit