S
S
Sasha Brahms2015-11-14 20:17:51
JavaScript
Sasha Brahms, 2015-11-14 20:17:51

unserialize js?

An array is passed from php to js:

array(
[0] =>
array( 
'one' => 1,
'two' => 2,
'three' => 'a:2:{s:3:"one";i:1;s:3:"two";s:3:"dva";}',
'four' => 4
),
[1] => array(....
...
...

how to unserialize 'three' on the client side?
but it’s expensive to do something on the server, sort through the entire array (here for an example, in mine it is much larger and not 1) and unserialize ..,
is there a solution?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexey Ukolov, 2015-11-14
@Dlike

https://github.com/naholyr/js-php-unserialize
Well, there are many more options here.

J
Just Me, 2017-09-11
@Just__Den

php: echo json_encode( unserialize( $array));
js: JSON.parse(data);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question