Found 27759 Articles for Server Side Programming

C++ Program to Copy Strings

Chandu yadav
Updated on 24-Jun-2020 09:45:13

3K+ Views

A string is a one dimensional character array that is terminated by a null character. The value of a string can be copied into another string. This can either be done using strcpy() function which is a standard library function or without it.The program to copy a string without using strcpy() function is given as follows −Example Live Demo#include using namespace std; int main() {    char str1[100] = "Magic";    char str2[100];    int i;    for(i = 0; str1[i] != '\0'; i++)    str2[i] = str1[i];    str2[i] = '\0';    cout

array_multisort() function in PHP

Samual Sam
Updated on 23-Dec-2019 07:02:59

125 Views

The array_multisort() function sorts multiple or multi-dimensional arrays. It returns a sorted array.Syntaxarray_multisort(arr1, sort_order, sort_type, arr2, arr3, arr4...)Parametersarr1 − Array to be sortedsort_order − The sort order. The following are the possible values- SORT_ASC - Default. Sort in ascending order (A-Z)- SORT_DESC - Sort in descending order (Z-A)sort_type − The sort behavior. Following are the possible valuesSORT_REGULAR - Default. Compare elements normally (Standard ASCII)SORT_NUMERIC - Compare elements as numeric valuesSORT_STRING - Compare elements as string valuesSORT_LOCALE_STRING - Compare elements as string, based on the current locale (can be changed using setlocale())SORT_NATURAL - Compare elements as strings using "natural ordering" like ... Read More

array_merge_recursive() function in PHP

karthikeya Boyini
Updated on 30-Jul-2019 22:30:23

368 Views

The array_merge_recursive() function merges one or more arrays into one array recursively. The difference between this function and array_merge() is that if two or more elements have the same key, the array_merge_recursive() function forms the value as an array. In this case, array_merge() function considers the last one. Syntax array_merge_recursive(arr1, arr2, arr3, …) Parameters arr1 − Initial array to merge arr2 − Another array arr3 − Another array Return The array_merge_recursive() function returns an array in which the elements of all arrays passed in parameters are merged. The following is an example that merges two array ... Read More

array_merge() function in PHP

karthikeya Boyini
Updated on 30-Jul-2019 22:30:23

185 Views

The array_merge() function merges one or more arrays into one array. It returns an array in which the elements of all arrays passed in parameters are merged. Note − In case of same keys of two or more array elements, the last one overrides the other. Syntax array_merge(arr1, arr2, arr3, …) Parameters arr1 − Initial array to merge arr2 − Another array arr3 − Another array Return The array_merge() function returns an array in which the elements of all arrays passed in parameters are merged. The following is an example that merges two array with a ... Read More

array_map() function in PHP

Samual Sam
Updated on 24-Jun-2020 09:38:18

69 Views

The array_map() function sends each value of an array to a user-made function, which returns new values.Syntaxarray_map(callback, arr1, arr2 −, arr3 −, arr4 −, …)Parameterscallback− The callback functionarr1 − The array to be modifiedarr2 − The array to be modifiedarr3 − The array to be modifiedReturnThe array_map() function returns an array containing the values of the first array, after applying the user-made function to each one.Example Live DemoOutputArray ( [0] => 1 [1] => 4 [2] => 9 )ExampleLet us see another example to create array of arrays using array_map(). Live DemoOutputArray ( [0] => Array ( [0] => 1 [1] => steve [2] => cricket ) [1] => Array ( [0] => 2 [1] => david [2] => football ) [2] => Array ( [0] => 3 [1] => nadal [2] => tennis ) )

array_keys() function in PHP

karthikeya Boyini
Updated on 23-Dec-2019 07:05:09

201 Views

The array_keys() function returns all the keys of an array. It returns an array of all the keys in array.Syntaxarray_keys(arr, value, strict)Parametersarr − The array from which the keys will be returnedvalue − If the values are specified, then only the keys containing these values will be returned.strict − Determines if strict comparison (===) should be used during the search.ReturnThe array_keys() function returns an array of all the keys in array.Example Live DemoOutputArray ( [0] => one [1] => two [2] => three [3] => four )ExampleLet us see another example wherein we will find the key for a specific value ... Read More

array_key_exists() function in PHP

Samual Sam
Updated on 24-Jun-2020 09:38:49

85 Views

The array_key_exists() function checks if the specified key exists in the array. The function returns true if the key exists and false if the key does not exist.Syntaxarray_key_exists(key, arr)Parameterskey − Specify the key to be checked.arr − The array wherein we will find the key.ReturnThe array_key_exists() function returns true if the key exists and false if the key does not exist.Example Live DemoOutputKey is in the array!

array_intersect_ukey() function in PHP

karthikeya Boyini
Updated on 24-Jun-2020 09:39:15

29 Views

The array_intersect_ukey() function compares array keys, with an additional user-made function check, and returns the matches. The function returns an array containing the entries from the first array that are present in all of the other arrays.Syntaxarray_intersect_ukey(arr1, arr2, arr3, arr4, …, compare_func)Parametersarr1 − Array to compare from. Required.arr2 − Array to compare against. Required.arr3 − You can add more arrays to compare. Optional.arr4 − You can add more arrays to compare. Optional.compare_func − This callback function must return an integer than 0 if the first argument is considered to be respectively than the second.ReturnThe array_intersect_ukey() function returns an ... Read More

array_intersect_uassoc() function in PHP

Samual Sam
Updated on 24-Jun-2020 09:39:33

43 Views

The array_intersect_unassoc() function compares array keys and values, with an additional user-made function check, and returns the matches.Syntaxarray_intersect_unassoc(arr1, arr2, arr3, arr4, …, compare_func)Parametersarr1 − Array to compare from. Required.arr2 − Array to compare against. Required.arr3 − You can add more arrays to compare. Optional.arr4 − You can add more arrays to compare. Optional.compare_func − This callback function must return an integer than 0 if the first argument is considered to be respectively than the second.ReturnThe array_intersect_uassoc() function returns an array containing the entries from the first array that are not present in any of the other arrays.Example Live DemoOutputArray ... Read More

array_intersect_key() function in PHP

karthikeya Boyini
Updated on 30-Jul-2019 22:30:23

64 Views

The array_intersect_key() function compares array keys, and returns the matches. It returns an array containing all of the values in the first array whose values exist in all of the parameters. Syntax array_intersect_key(arr1, arr2, arr3, arr4, …) Parameters arr1 − Array to compare from. Required. arr2 − Array to compare against. Required. arr3 − You can add more arrays to compare. Optional. arr4 − You can add more arrays to compare. Optional. Return The array_intersect_key() function returns an array containing all of the values in the first array whose values exist in all of the ... Read More

Advertisements