Skip to content

Instantly share code, notes, and snippets.

@yoshitsugu
Created November 6, 2013 08:40
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save yoshitsugu/7332856 to your computer and use it in GitHub Desktop.
Save yoshitsugu/7332856 to your computer and use it in GitHub Desktop.
PHPのArrayをRubyのHashに変換。 PHP Array to Ruby Hash
function to_ruby_hash($array){
$result = "{";
foreach($array as $key => $value){
$result .= "\"".$key."\" => ";
if(is_array($value)){
$result .= to_ruby_hash($value).",\n";
}else{
$result .= "\"".$value."\",";
}
}
return $result."}";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment