All Articles
PHP Snippets
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…
PHP Snippets
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…
PHP Snippets
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…
PHP Snippets
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…
PHP Snippets
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…
Javascript
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:
Javascript
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:
Javascript
Unzip an array of arrays
This function ‘unzips’ an array of tuples into multiple arrays, reversing the ‘zip’ operation. JavaScript: TypeScript:
Javascript
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…
Javascript
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:
Recent comments