Found 35502 Articles for Programming

pos() function in PHP

Samual Sam
Updated on 23-Dec-2019 08:11:04

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

natsort() function in PHP

karthikeya Boyini
Updated on 23-Dec-2019 08:09:43

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 )

list() function in PHP

karthikeya Boyini
Updated on 23-Dec-2019 08:08:30

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.

krsort() function in PHP

Samual Sam
Updated on 24-Jun-2020 12:31:15

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

in_array() function in PHP

karthikeya Boyini
Updated on 24-Jun-2020 12:25:42

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

end() function in PHP

Samual Sam
Updated on 23-Dec-2019 07:48:35

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

current() function in PHP

karthikeya Boyini
Updated on 23-Dec-2019 07:47:20

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

compact() function in PHP

Samual Sam
Updated on 23-Dec-2019 07:42:32

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

arsort() function in PHP

karthikeya Boyini
Updated on 24-Jun-2020 12:27:01

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

array_walk() function in PHP

Samual Sam
Updated on 24-Jun-2020 12:27:25

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

Advertisements