unserialize function in PHP.
Step 1: Serialize the PHP Array
The first step is to serialize the PHP array using the
<?php $myArray = array( 'name' => 'John Doe', 'age' => 30, 'gender' => 'male' ); $serialized = serialize($myArray); ?>
<script> var myArray = '<?php echo $serialized; ?>'; </script>
myArray that contains the serialized PHP array.
<script> var myArray = '<?php echo $serialized; ?>'; var myObject = JSON.parse(myArray); </script>
myObject that contains the same data as the original PHP array.