PHP-Serialized to JavaScript-Unserialized -
- in php:
$value = serialize($randomarray);
- the
$value
available{{value}}
twig. - in javascript:
var value = {{value}};
- how unserialize value in javascript array?
from twig's documentation:
json_encode
the json_encode filter returns json representation of string:
{{ data|json_encode() }}
so try {{ value|json_encode() }}
, see if array available javascript.
note: may have unserialize $value before passing json_encode
. without trying myself don't know spit out. json_encode
lovely job php array-to-javascript array/object.
Comments
Post a Comment