Created
November 6, 2013 08:40
-
-
Save yoshitsugu/7332856 to your computer and use it in GitHub Desktop.
PHPのArrayをRubyのHashに変換。
PHP Array to Ruby Hash
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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