Found 27759 Articles for Server Side Programming

array_diff() function in PHP

Samual Sam
Updated on 30-Jul-2019 22:30:23

49 Views

The array_diff() function compares array values, and returns the differences. It returns an array containing the entries from the first array that are not present in any of the other arrays. Syntax array_diff(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_diff() function returns an array containing the entries from the first array that are not present in any of the other ... Read More

array_count_values() function in PHP

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

5K+ Views

The array_count_values() function returns an array with the number of occurrences for each value. It returns an associative array. The returned array has keys as the array’s values, whereas values as the count of the passed values. Syntax array_count_values(arr) Parameters arr − The array for which we want to count the values. Return The array_count_values() function returns an associative array. The returned array has keys as the array’s values, whereas values as the count of the passed values. Example Live Demo Output Array ( [Laptop] => 1 [Keyboard] => 4 [Mouse] => 2 )

array_combine() function in PHP

Samual Sam
Updated on 23-Dec-2019 06:40:08

92 Views

The array_combine() function creates an array by using one array for keys and another for its values. It returns the combined array. The function returns FALSE if the number of elements of each array does not match.Syntaxarray_combine(keys, values);Parameterskeys − Array of keys.values − Array of values.ReturnThe array_combine() function returns the combined array. It returns FALSE if the number of elements of each array does not match.The following is an example combining two arrays.Example Live DemoOutputThe following is the output −Array ( [football] => david [cricket] => steve )

array_chunk() function in PHP

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

51 Views

The array_chunk() function splits an array into chunks of arrays. It returns a multidimensional numerically indexed array, starting with zero. Syntax array_chunk(arr, chunk_size, preserve_key) Parameters arr − The array chunk_size − The size of chunk in integer preserve_key − It has the following values: TRUE- Keys are preserved, FALSE: The chunk is reindexed. Return The array_chunk() function returns a multidimensional numerically indexed array, starting with zero. The following is an example that shows how an array is split. Example Live Demo Output Array ( [0] => Array ( [Electronics] => 99 [Accessories] => 110 ) [1] => Array ( [Clothing] => 150 [Furniture] => 198 ) )

array_change_key_case() function in PHP

Samual Sam
Updated on 30-Jul-2019 22:30:23

228 Views

The array_change_key_case returns an array with all keys in lowercase or uppercase. It returns an array with its keys in lowercase or uppercase. It returns FALSE if array is not an array. Syntax array_change_key_case(arr, case) Parameters arr − The array. Required. case − Specify the case. The default is Lowercase i.e. CASE_LOWER. Optional. Return The array_change_key_case() function returns an array with its keys in lowercase or uppercase. It returns FALSE if array is not an array. The following is an example to convert all keys to uppercase. Example Live Demo Output ... Read More

array() function in PHP

karthikeya Boyini
Updated on 24-Jun-2020 09:33:58

158 Views

The array() function in PHP creates an array.Array is of three types in PHP.Indexed arrays − It is an array with numeric indexAssociative arrays − It is an array with named keysMultidimensional arrays − It is an array that have one or more arraysSyntax// array with numeric index i.e. Indexed arrays array(value1, value2...); // array with named keys i.e. associative arrays array(key1 => value1, key2 => value2...)Parametersvalue − Set the value.key − Set the key.ReturnThe array() function returns an array of the parameters.The following is an example of indexed arrays.Example Live DemoOutputElectronics Clothing Accessories FootwearThe following is an example of associative ... Read More

unlink() function in PHP

Samual Sam
Updated on 24-Jun-2020 09:34:11

1K+ Views

The unlink() function deletes a file. It returns TRUE on success, or FALSE on failure. It returns TRUE on success and FALSE on failure.Syntaxunlink(file_path, context)Parametersfile_path − Set the name of the file to be deleted.context − Set the behavior of the stream.ReturnThe unlink() function returns TRUE on success and FALSE on failure.Example Live DemoOutputFile can’t be deleted!

umask() function in PHP

karthikeya Boyini
Updated on 24-Jun-2020 09:34:29

193 Views

The umask() function changes permissions for files. It returns the current umask is it is set without arguments.Syntaxumask(mask)Parametersmask − Set the new permission.ReturnThe umask() function returns the current umask is it is set without arguments.ExampleOutputAccess changed!

touch() function in PHP

Samual Sam
Updated on 24-Jun-2020 09:34:52

202 Views

The touch() function sets access and modification time of a file. It returns TRUE on success, or FALSE on failure.Syntaxtouch(filename, time, atime)Parametersfilename − Set the name of the file.time − Set the time. The default is the current system time.atime − Set the access time. The default is the current system time.ReturnThe touch() function returns TRUE on success, or FALSE on failure.Example Live DemoOutputThe modification time of new.txt set to current time.Let us see another example.Example Live DemoOutputThe modification time of new.txt updated to 8 hrs in the past.

tmpfile()function in PHP

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

37 Views

The tmpfile() function creates a unique temporary file. It returns file pointer for the new file or FALSE on failure. Syntax tmpfile() Parameters NA Return The tmpfile() function returns file pointer for the new file or FALSE on failure. Example Live Demo Output This is demo text in temp file!

Advertisements