ssc37 has asked for the wisdom of the Perl Monks concerning the following question:

Hi,
It's my first post on perlmonks because I always find my answers on google ^^ but not this time...
I need to print a perl hash (include multiple level,array) in php format for some reason.
Does someone knows how to do it?
Does a module already exist to realise this?
Thanks for your support
Best regards
  • Comment on Perl Hashes => Php array: existant module?

Replies are listed 'Best First'.
Re: Perl Hashes => Php array: existant module?
by ikegami (Patriarch) on Dec 09, 2009 at 18:27 UTC
    Does it have to be in PHP format, or in a format for which there's a ready made module for PHP? I'm pretty sure JSON and YAML have PHP bindings, and both are designed to store such structures simply.
      In the best way i prefere it to be in PHP format, because i need to include the result in a php page.
      But to solve my problem if i have to use a xml writer and after use a php2xml parser to put my hash in a multidimensional php array i don't care ^^
      Which way is the best? (write my page in perl?.. ^^)
      Does a php writer exists? or do you know a easy xml writer to generate a xml with a multidimensional hash?
      Best regards and thanks for you answer ikegami :)
Re: Perl Hashes => Php array: existant module?
by superfrink (Curate) on Dec 09, 2009 at 20:33 UTC
      I've took a look about PHP::Session and not seen something interesting for my deal.
      I browse cpan yesterday and found the module PHP::Serialization, but i'm not sure it dump a php array.
      I've just tried XML::Dumper but it didn't print all informations of my hashes just the first keys.... so i test with Data::DumpXML and everything is ok ^^
      Last step, parse this xml file to retrieve an array in my php page

      Cheers for yours informations and for this nice website
      Best regards Ps: i hope you understand my sad english ^^ i'm french
        After take a look at my output xml file generated by XML::Dumper, i've seen some key encode in base64 ... :s due to some accent or characters like 'ιθ' etc..
        Do you know a way to solve it?
        Thanks