PHP-Serialized to JavaScript-Unserialized -


  1. in php: $value = serialize($randomarray);
  2. the $value available {{value}} twig.
  3. in javascript: var value = {{value}};
  4. 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

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -