PHP code example of mochaka / serialization-parser

1. Go to this page and download the library: Download mochaka/serialization-parser library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

mochaka / serialization-parser example snippets


use Mochaka\SerializationParser\SerializationParser;
$data = serialize(['foo' => 'bar', 'baz' => 1]);
$result = SerializationParser::parse($data);

var_dump($result);
Mochaka\SerializationParser\Data\ArrayType {#4172
    +name: null,
    +visibility: null,
    +properties: [
      Mochaka\SerializationParser\Data\StringType {#4170
        +name: "foo",
        +visibility: null,
        +value: "bar",
      },
      Mochaka\SerializationParser\Data\IntegerType {#4171
        +name: "baz",
        +visibility: null,
        +value: 1,
      },
    ],
  }

var_dump($result->toArray());

[
    "name" => null,
    "properties" => [
      [
        "name" => "foo",
        "type" => "String",
        "value" => "bar",
        "visibility" => null,
      ],
      [
        "name" => "baz",
        "type" => "Integer",
        "value" => 1,
        "visibility" => null,
      ],
    ],
    "type" => "Array",
    "visibility" => null,
  ]