Skip to content

Instantly share code, notes, and snippets.

@macik
Created February 11, 2013 22:11
Show Gist options
  • Save macik/4758083 to your computer and use it in GitHub Desktop.
Save macik/4758083 to your computer and use it in GitHub Desktop.
Short arabic2roman conveter
<?php
function rome($N){
$c='IVXLCDM';
for($a=5,$b=$s='';$N;$b++,$a^=7)
for($o=$N%$a,$N=$N/$a^0;$o--;$s=$c[$o>2?$b+$N-($N&=-2)+$o=1:$b].$s);
return $s;
}
?>
@lpaseen
Copy link

lpaseen commented Feb 29, 2016

Tried it and while it seems to work it fills my logfile with

PHP Warning: Illegal string offset '' in ...

and the line it points to is
for($o=$N%$a,$N=$N/$a^0;$o--;$s=$c[$o>2?$b+$N-($N&=-2)+$o=1:$b].$s);
I'm guessing $c[] is the issue, it need some value in there.

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