MemoryRefresh!

Storage



Questions 1 Answers 0%

Pages   0 from 51
Questions   0 from 84

Reset



serialize() - Generates a storable representation of an array (or object)
<?php $data = array( 'firstname' => 'John', 'name' => 'Smith', 'age' => 30, ); echo $string = serialize($data); // a:3:{s:9:"firstname";s:4:"John";s:4:"name";s:5:"Smith";s:3:"age";i:30;} $result = unserialize($string); print_r($result); // Array ( [firstname] => John [name] => Smith [age] => 30 ) json_encode() - Returns a string containing the json representation
<?php $arr = array('a' => 1, 'b' => 2, 'c' => 3); echo $json = json_encode($arr); // {"a":1,"b":2,"c":3} $arr2 = json_decode($json); var_dump($arr2); /* object(stdClass)[1] public 'a' => int 1 public 'b' => int 2 public 'c' => int 3 */
Questions

Related pages

Basics !
Operations !
Create !
Key-value !
Search !
Modify !
Pointer !
Sort !
Stacks !
Randomize !
Storage !


0% 100%
 
 
0 pages 51 pages
1) Get the json representation of an array





2) Decode the array from string <?php $string = 'a:2:{s:9:"firstname";s:4:"John";s:4:"name";s:5:"Smith";}';




Last Review: n/a   Passed: n/a   Reviews: n/a   Next Review: n/a  


serialize() - Generates a storable representation of an array (or object)
<?php $data = array( 'firstname' => 'John', 'name' => 'Smith', 'age' => 30, ); echo $string = serialize($data); // a:3:{s:9:"firstname";s:4:"John";s:4:"name";s:5:"Smith";s:3:"age";i:30;} $result = unserialize($string); print_r($result); // Array ( [firstname] => John [name] => Smith [age] => 30 ) json_encode() - Returns a string containing the json representation
<?php $arr = array('a' => 1, 'b' => 2, 'c' => 3); echo $json = json_encode($arr); // {"a":1,"b":2,"c":3} $arr2 = json_decode($json); var_dump($arr2); /* object(stdClass)[1] public 'a' => int 1 public 'b' => int 2 public 'c' => int 3 */



More from Php

Basics
Variables
Operators
Function
Array
String
Streams
Uncategorized


More from Programming

Php
jQuery




Powered by minte9.com