Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
raku, Inline::Perl5 and PHP::Serialize
#phpsmake.php
1 #!/bin/env php
2 <?php
3
4 $array = [
5 "foo" => "bar",
6 "bar" => "foo",
7 ];
8
9 #print( var_dump($array) );
10
11 $as = serialize($array);
12 print( $as );
13
14 ?>
./phpsmake.php > dump.txt
#phptest.raku
1 use Inline::Perl5;
2 use PHP::Serialization:from<Perl5> <serialize unserialize>;
3
4 my $encoded = serialize({ a => 1, b => 2});
5 my $hashref = unserialize($encoded);
6 say $encoded;
7 say $hashref;
8
9 my $phpbuf = 'dump.txt'.IO.slurp;
10 say $phpbuf;
11 my $result = unserialize($phpbuf);
12
13 say $result;
raku phpstest.raku
a:2:{s:1:"a";i:1;s:1:"b";i:2;}
{a => 1, b => 2}
a:2:{s:3:"foo";s:3:"bar";s:3:"bar";s:3:"foo";}
{bar => foo, foo => bar}
@p6steve
Copy link
Author

p6steve commented Aug 4, 2022

make public

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment