PHP Snippets
Redirect To Another Page
This function redirects the user to another page. It uses PHP’s header function to send a ‘Location’ HTTP header with…
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
Check If Array Is Associative
This function checks if an array is associative. It compares the array’s keys with a range of integers from 0…
PHP Snippets
Get The Current Page URL
This function returns the current page URL. It concatenates the server’s host name and the request URI from PHP’s superglobal…
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 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 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
Find the minimum item of a set
This function returns the minimum value from a set. JavaScript: TypeScript:
Javascript
Remove an item from a set
This function removes an item from a set. JavaScript: TypeScript:
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: