All Articles

Generate a Random String

This function generates a random string of a specified length. It uses str_shuffle to randomize a string of all alphanumeric…

Get The First Element Of An Array

This function returns the first element of an array. It uses PHP’s reset function which sets the internal pointer of…

Check If String Contains Another String

This function checks if a given string contains another string. It uses PHP’s strpos function which returns the position of…

Check If String Starts With Another String

This function checks if a given string starts with another string. It also uses strpos but checks specifically if the…

Check If String Ends With Another String

This function checks if a given string ends with another string. It uses substr to get the ending part of…

Check if a set is a subset of another set

This function checks whether the first set is a subset of the second set. JavaScript: TypeScript:

Find the intersection of two sets

This function finds the intersection of two sets, i.e., elements that are common to both sets. JavaScript: TypeScript:

Unzip an array of arrays

This function ‘unzips’ an array of tuples into multiple arrays, reversing the ‘zip’ operation. JavaScript: TypeScript:

Find the difference of two sets

This function finds the difference of two sets, i.e., elements that are in the first set but not in the…

Create a set from an array

This function creates a set from an array. The set contains all unique elements of the array. JavaScript: TypeScript: