Skip to content

swiftmade/simple-serialization

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

{ Simple Serialization

This is a PHP package that serves a very simple purpose: Serialize associative string arrays.

Why?

We are using this package to turn some data into SMS messages and then convert SMS messages back to PHP arrays. You can use it for any purpose you like, when json_encode or serialize is overkill.

Features

  • Simple API: simple_serialize($array) and simple_unserialize($string)
  • Your keys or values can contain quotes, whitespaces, etc. No escaping needed.
  • The only limitation is, your keys cannot contain colon (:) and your values cannot contain semi-colon (;)
  • Tolerates syntax errors! It will still extract the valid bits of data.

Usage

Installation:

composer require swiftmade/simple-serialization

Serialize:

$array = ['your_key' => 'whatever information'];
$string = simple_serialize($array); // "your_key:whatever information"

Unserialize:

$string = "your_key:whatever information";
$array = simple_unserialize($string); // ['your_key' => 'whatever information'];

About

Simple PHP serialization library

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages