Skip to content

POPSuL/php-serialize

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

php-serialize

Coverage

Go-based decoder for php-serialized objects.

Usage

// php -r 'echo serialize(["foo" => "bar"]);' -> a:1:{s:3:"foo";s:3:"bar";}

import "github.com/popsul/php-serialize/v2/decoder"

// ...

obj, err := decoder.Decode([]byte(`a:1:{s:3:"foo";s:3:"bar";}`))
if err != nil {
    panic(err)
}
fmt.Println(obj.Type) // a
for key := range obj.Array {
    fmt.Println(key.Type) // i for array or s for hashes and sprarced arrays
    fmt.Println(key.Str) // foo
    arrValue = obj.Array[key]
    fmt.Println(arrValue.Type) // s
    fmt.Println(arrValue.Str) // bar
}

Supported types

  • i -- integer
  • d -- double (float)
  • b -- boolean
  • s -- string
  • a -- array
  • o -- object
  • n -- null

License

MIT

About

Go-based decoder for php-serialized objects

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages