Conversion Filters

  • base64_decode - Decodes the value represented as base64 and returns the result.

  • base64_decode_urlsafe - Decodes the value represented as base64 URL safe text and returns the result.

  • base64_encode - Encodes the value and returns the result as base64 text.

  • base64_encode_urlsafe - Encodes the value and returns the result as base64 URL safe text.

  • base_convert - Converts a value between two bases.

  • bin2hex - Converts a binary value into its hex equivalent.

  • decbin - Converts a decimal value into its binary string (i.e. 01010) equivalent.

  • bindec - Converts a binary string (i.e. 01010) into its decimal equivalent.

  • create_object - Creates an object based on a list of keys and a list of values.

  • csv_decode - Decodes the value represented as CSV and returns the result

  • csv_encode - Encodes the value and returns the result in CSV-formatted text

  • dechex - Converts a decimal value into its hex equivalent.

  • decoct - Converts a decimal value into its octal equivalent.

  • hex2bin - Converts a hex value into its binary equivalent.

  • hexdec - Converts a hex value into its decimal equivalent.

  • json_decode - Decodes the value represented as json and returns the result.

  • json_encode - Encodes the value and returns the result as json text.

  • octdec - Converts an octal value into its decimal equivalent.

  • to_bool - Converts text, integer, or decimal types to a bool and returns the result.

  • to_dec - Converts text, integer, or bool types to a decimal and returns the result.

  • to_int - Converts text, integer, or bool types to an integer and returns the result.

  • to_text - Converts text, integer, or bool types to text and returns the result.

  • to_timestamp - Converts a text expression (now, next Friday) to timestamp comparable format.

  • url_decode - Decodes the value represented as a URL encoded value.

  • url_decode_rfc3986 - Decodes the value represented as a URL encoded value conforming to RFC3986 specifications

  • url_encode - Encodes the value and returns the result as a URL encoded value.

  • url_encode_rfc3986 - Encodes the value and returns the result as a URL encoded value conforming to RFC3986 specifications

  • yaml_decode - Decodes the value represented as yaml and returns the result.

  • yaml_encode - Encodes the value and returns the result as yaml text.

  • xml_decode - Decodes the value represented as XML to JSON and returns the result

base64_decode:

Decodes the value represented as base64 and returns the result.

base64_decode_urlsafe:

Decodes the value represented as base64 URL safe text and returns the result.

This filter transforms the base64 URL safe encoded characters -_. back to +/=.

base64_encode:

Encodes the value and returns the result as base64 text.

base64_encode_urlsafe:

Encodes the value and returns the result as base64 URL safe text.

In base64 encoding, a URL safe format is not taken into consideration but there's only three characters we need to be cautious of +/=. With this filter those characters become -_. respectively.

base_convert:

Converts a value between two bases.

  • frombase: Specifies the original base of number. Has to be between 2 and 36, inclusive. Digits in numbers with a base higher than 10 will be represented with the letters a-z, with a meaning 10, b meaning 11 and z meaning 35

  • tobase: Specifies the base to convert to. Has to be between 2 and 36, inclusive. Digits in numbers with a base higher than 10 will be represented with the letters a-z, with a meaning 10, b meaning 11 and z meaning 35

In this example we are converting a hexadecimal number to an octal number:

bin2hex:

Converts a binary value into its hex equivalent.

decbin:

Converts a decimal value into its binary string (i.e. 01010) equivalent.

bindec:

Converts a binary string (i.e. 01010) into its decimal equivalent.

create_object:

Creates an object based on a list of keys and a list of values.

Resulting in a created object:

csv_decode:

Decodes the value represented in the CSV format and returns the result.

  • separator - the field delimiter, one character only (usually a comma)

  • enclosure - the field enclosure, one character only (usually a quotation mark)

  • escape - the escape character that allows the enclosure character to be used within a field

csv_encode:

Encodes the value and returns the result in CSV format

  • separator - the field delimiter, one character only (usually a comma)

  • enclosure - the field enclosure, one character only (usually a quotation mark)

  • escape - the escape character that allows the enclosure character to be used within a field

dechex:

Converts a decimal value into its hex equivalent.

decoct:

Converts a decimal value into its octal equivalent.

hex2bin:

Converts a hex value into its binary equivalent.

hexdec:

Converts a hex value into its decimal equivalent.

json_decode:

Decodes the value represented as json and returns the result. We will decode the json from the json_encode filter example.

json_encode:

Encodes the value and returns the result as json text. The variable object is: { "a":"3", "b":"2", "c":"1" }.

octdec:

Converts an octal value into its decimal equivalent.

to_bool:

Converts text, integer, or decimal types to a bool and returns the result. The different conversions that are possible with this filter are: Converting a text/integer/decimal value of 0 to false. Converting a text/integer/decimal value of 1 to true. Converting a text value of "true" to true. Converting a text value of "false" to false.

to_decimal:

Converts text, integer, or bool types to a decimal and returns the result.

to_int:

Converts text, decimal, or bool types to an integer and returns the result.

to_text:

Converts text, decimal, or bool types to text and returns the result.

to_timestamp:

Converts a text expression (now, next Friday) to timestamp comparable format.

url_decode:

Decodes the value represented as a URL encoded value.

url_decode_rfc3986

Similar to url_decode, this decodes the value represented as a URL encoded value, but conforming to rfc3986 standards.

url_encode:

Encodes the value and returns the result as a URL encoded value.

url_encode_rfc3986

Similar to url_encode, this encodes the value and returns the result as a URL encoded value, but conforming to rfc3986 standards.

yaml_decode:

Decodes the value represented as yaml and returns the result. For this example, we will use the example from yaml encode and then decode the variable. The variable gets changed into:

{
  "name": "John",
  "age": 30,
  "car": "ford"
}

yaml_encode:

Encodes the value and returns the result as yaml text.

xml_decode:

Decodes the provided data as XML, to JSON, and returns the result.

Last updated