You are here

snippet - Number to words in PHP
24 Jul, 2018
Helper function for converting numbers to words. There is same function available in PHPs NumberFormatter class, but using it is not always possible, since it's not enabled by default.
snippet - PHP: First x characters of a string
2 Nov, 2017
Get first n amount of characters from a string. You could use substr for that, but you will get empty results when there are special characters. Thus multibyte string method is the right way to go.
snippet - Explode multiple delimiters PHP
4 Jan, 2016
To explode multiple delimiters PHP you have to use regular expression. Add your delimiters in the parentheses separated by pipe. You might have to escape your characters if they have meaning in PCRE...
snippet - PHP: Replace all whitespaces with a single space
8 Sep, 2015
You can replace all whitespaces (space, new lines, etc.) with a single space using regular expression find and replace.
snippet - Validate UTF-8 strings in PHP
7 May, 2014
This function checks whether a string is valid UTF-8. You can ensure that the string you operate is a valid UTF-8 string. preg_match fails on strings containing invalid UTF-8 byte sequences. It does...
snippet - Convert text or HTML to plain-text in PHP
25 Nov, 2013
Encodes special characters in a plain-text string for display as HTML. Validates strings as UTF-8, if not UTF-8 it returns an empty string. It prevents CSS attacks on IE 6.
snippet - Detect character encoding in PHP
26 Apr, 2012
Detect character encoding in PHP and convert string to UTF-8.