Please critique my function
This was for a simple assignment - ok,not simple for me. I had to write a function to compare 2 roman numerals. This had to return true only if the second number was larger than the first and had to be done without converting the letters into actual numbers. Also prefix subtraction didn't apply so all the letters came in descending order.

Here is what I came up with:


    <?php

    function x_smaller_than_y($x_num,$y_num) {
    $evaluation= array("M","D","C","L","X","V","I");

    $x_num_arr = str_split($x_num);
    $y_num_arr = str_split($y_num);

    for ($evaluate = 0; $evaluate<7;$evaluate++)
      {  
         $counter = 0;
         while ($counter < ((strlen($x_num)))&& $counter < ((strlen($y_num))))
           {
           if ($x_num_arr[$counter]==$y_num_arr[$counter])
               {$counter++;}

           elseif(($x_num_arr[$counter]!=$evaluation[$evaluate])&&($y_num_arr[$counter]==$evaluation[$evaluate]))
               {return true;
                $evaluate=8;
                break;}

           elseif(($x_num_arr[$counter]==$evaluation[$evaluate])&&( $y_num_arr[$counter]!=$evaluation[$evaluate]))
               {return false;
                $evaluate=8;
                break;}    

           else {$counter++;}
            }
        }

    if ($evaluate<8&&(strlen($x_num) < strlen($y_num)))
    {return true;}

    elseif ($evaluate<8&&(strlen($x_num) > strlen($y_num)))
    {return false;}

    }

Please critique my function
===

This was for a simple assignment - ok,not simple for me. I had to write a function to compare 2 roman numerals. This had to return true only if the second number was larger than the first and had to be done without converting the letters into actual numbers. Also prefix subtraction didn't apply so all the letters came in descending order.

Here is what I came up with:


    <?php

    function x_smaller_than_y($x_num,$y_num) {
    $evaluation= array("M","D","C","L","X","V","I");

    $x_num_arr = str_split($x_num);
    $y_num_arr = str_split($y_num);

    for ($evaluate = 0; $evaluate<7;$evaluate++)
      {  
         $counter = 0;
         while ($counter < ((strlen($x_num)))&& $counter < ((strlen($y_num))))
           {
           if ($x_num_arr[$counter]==$y_num_arr[$counter])
               {$counter++;}

           elseif(($x_num_arr[$counter]!=$evaluation[$evaluate])&&($y_num_arr[$counter]==$evaluation[$evaluate]))
               {return true;
                $evaluate=8;
                break;}

           elseif(($x_num_arr[$counter]==$evaluation[$evaluate])&&( $y_num_arr[$counter]!=$evaluation[$evaluate]))
               {return false;
                $evaluate=8;
                break;}    

           else {$counter++;}
            }
        }

    if ($evaluate<8&&(strlen($x_num) < strlen($y_num)))
    {return true;}

    elseif ($evaluate<8&&(strlen($x_num) > strlen($y_num)))
    {return false;}

    }
