-
Notifications
You must be signed in to change notification settings - Fork 1
ConvertHelper
Mistralys edited this page Nov 13, 2019
·
4 revisions
As the name implies, this class is used mainly for converting data of all kinds. However, it also has a number of useful utility functions.
The ConvertHelper class is entirely static. It does not require any configuration.
- explodeTrim: Explodes a string, trims the entries, and removes empty entries.
- findString: Slightly different strstr or stristr, which returns the matched strings.
- string2array: Splits a string into a characters array, unicode safe.
- string2attributeJS: Escapes a string to be inserted into a JavaScript statement in an HTML tag.
- string2bool: Converts a boolean string representation to a boolean value (yes/no/true/false...).
- string2bytes: Counts the amount of bytes a string uses, unicode safe.
- string2hash: Converts a string to a hash string (MD5).
- string2shortHash: Converts a string to a shorter hash (CRC32).
- string2utf8: Converts any string to valid UTF-8.
- stripControlCharacters: Strips all invisible control characters from a string.
- stripUTFBom: Strips a UTF Byte Order Mark from a string, if any.
- tabs2spaces: Converts all tabs to spaces in a string.
- text_cut: Cuts a string at the specified length.
- transliterate: Converts a string to a machine readable ASCII string.
- wordwrap: Word wraps a string to a specific line length.
- array2attributeString: Converts an associative array to an HTML attribute string.
- array2styleString: Converts an associative array to a CSS style string.
- implodeWithAnd: Implodes a list of strings with commas and "and" at the end, localized.
- date2dayName: Converts a DateTime object to a localized day name.
- date2listLabel: Converts a DateTime object to a human readable string.
- date2timestamp: Converts a DateTime object to a timestamp.
- duration2string: Converts a timespan between two dates into a human readable string.
- getDayNames: Returns a list of localized day names (long or short).
- getDayNamesInvariant: Retrieves a list of english day names.
- interval2string: Converts a DateInterval object to a human readable string.
- interval2total: Calculates the total amount of days, hours, minutes or seconds in a DateInterval.
- month2string: Converts a month number to a localized month name.
- time2string: Converts seconds into a human readable duration string.
- timestamp2date: Converts a timestamp to a DateTime object.
- areNumbersEqual: Checks if two numbers are equal.
- areStringsEqual: Checks if two strings are equal.
- areVariablesEqual: Checks if two variables are equal.
- isBoolean: Checks if the value can be considered boolean (string, numeric, etc).
- isStringASCII: Checks if the string is ASCII, i.e. contains no special or unicode characters.
- isStringHTML: Checks if the string contains HTML code.
- highlight_php: Highlight a PHP string.
- highlight_sql: Highlight an SQL string.
- highlight_url: Highlight the logical parts of an URL.
- highlight_xml: Highlight an XML string.
- callback2string: Converts a callable value to a human readable string.
- bytes2string: Converts bytes to a human readable value.
-
exception2info: Alias for
throwable2Info()
. - throwable2info: Converts a throwable object to a class with a handy API to retrieve info about it.
New here?
Have a look at the overview for a list of all helper classes available in the package.
Table of contents
Find the current page in the collapsible "Pages" list above, and expand the page, to view a table of contents.