PHP Serialize

Performs PHP serialization on JSON data.

Input: Structured JSONResult: Text

Text input

Run to see the result

Examples

PHP Serialize array

Input

[1,"abc",true,{"x":1,"y":2}]

Expected answer

a:4:{i:0;i:1;i:1;s:3:"abc";i:2;b:1;i:3;a:2:{s:1:"x";i:1;s:1:"y";i:2;}}
PHP Serialize boolean

Input

[true, false]

Expected answer

a:2:{i:0;b:1;i:1;b:0;}
PHP Serialize empty array

Input

[]

Expected answer

a:0:{}
PHP Serialize empty object

Input

{}

Expected answer

a:0:{}
PHP Serialize float

Input

14.523

Expected answer

d:14.523;
PHP Serialize integer

Input

10

Expected answer

i:10;
PHP Serialize null

Input

null

Expected answer

N;
PHP Serialize object

Input

{"a": 10,"0": {"ab": true}}

Expected answer

a:2:{s:1:"0";a:1:{s:2:"ab";b:1;}s:1:"a";i:10;}
PHP Serialize string

Input

"Test string to serialize"

Expected answer

s:24:"Test string to serialize";

This function does not support object tags. Since PHP doesn't distinguish dicts and arrays, this operation is not always symmetric to PHP Deserialize. Example: [5,"abc",true] becomes a:3:{i:0;i:5;i:1;s:3:"abc";i:2;b:1;}

Format reference: PHP Serialize background and specification

Related tools

Browse code tidy tools