php_serializer 1.2.0 copy "php_serializer: ^1.2.0" to clipboard
php_serializer: ^1.2.0 copied to clipboard

Serialize and deserialize Strings that the Php-Functions serialize created or unserialize can parse, so Dart code can communicate with Php in its native format

example/example.md

Transfer data from Php to Dart #

<?php
$trivialArray = [
    1, 1, 2, 3, 5, 8
];
echo serialize($trivialArray);
//Output: a:6:{i:0;i:1;i:1;i:1;i:2;i:2;i:3;i:3;i:4;i:5;i:5;i:8;}
void main() {
  String inputFromPhp = 'a:6:{i:0;i:1;i:1;i:1;i:2;i:2;i:3;i:3;i:4;i:5;i:5;i:8;}';
  assert([1, 1, 2, 3, 5, 8] == phpDeserialize(inputFromPhp));
}

Transfer data from Dart to Php #

void main() {
  List<int> trivialList = [1, 1, 2, 3, 5, 8];
  print(phpSerialize(trivialList));
  //Output: a:6:{i:0;i:1;i:1;i:1;i:2;i:2;i:3;i:3;i:4;i:5;i:5;i:8;}
}
<?php
$inputFromDart = 'a:6:{i:0;i:1;i:1;i:1;i:2;i:2;i:3;i:3;i:4;i:5;i:5;i:8;}';
\assert([1, 1, 2, 3, 5, 8] === unserialize($inputFromDart));
9
likes
160
points
145
downloads

Publisher

verified publishermanu311.de

Weekly Downloads

Serialize and deserialize Strings that the Php-Functions serialize created or unserialize can parse, so Dart code can communicate with Php in its native format

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-2-Clause (license)

More

Packages that depend on php_serializer