unserialize

Filter to unserialize a variable. Equivalent to PHP’s unserialize($variable)

  1. Returns
  2. Examples

Returns

The converted value is returned, and can be a boolean, integer, float, string, array or object.

In case the passed string is not unserializeable, FALSE is returned and E_NOTICE is issued.

Examples

{# If you have serialized a variable in session you can recover it and unserialize it in twig #}
{% set cartItems = jsession.get('cartItems', []) %}
{% if cartItems is not iterable %}
	{% set cartItems = cartItems|unserialize %}
{% endif %}