3999 || $f 1000, 'd' => 500, 'c' => 100, 'l' => 50, 'x' => 10, 'v' => 5, 'i' => 1 ); // calculate the needed roman figures: foreach($roman as $k => $v) if(($amount[$k] = floor($f / $v)) > 0) $f -= $amount[$k] * $v; // build the string: $return = ''; foreach($amount as $k => $v) { $return .= $v 1000, 'd' => 500, 'c' => 100, 'l' => 50, 'x' => 10, 'v' => 5, 'i' => 1 ); // convert the string to an array of roman values: for($i = 0; $i $current ? $sum += $next - $current + 0 * next($values) : $sum += $current; } // return the value: return $sum;}// echo roman2dec(ix); ?>
希望本文所述对大家的php程序设计有所帮助。
