php_serializer 1.2.0 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
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));