Pramod Kumar Sharma
Pramod Kumar Sharma

Reputation: 8012

Sort roman number in php

I have a classes in roman number like

    I
    II 
    III
    IV
    IX
    V
    VI
    VII
    XI Commerce
    XI Arts 
    XI Science

i have tried sorting by roman number function but due to extra string are there with XI class like arts, commerce so its now working as per aspected. Is there any way to come out with any result.

enter image description here

Upvotes: 1

Views: 809

Answers (2)

shark
shark

Reputation: 325

explode string first to get the roman numerals.

$str = explode(" ",$yourstring);
$roman = $str[0]; //the roman numerals
$subject = $str[1]; //the subject;

then make a function to convert roman numerals to numbers.

Upvotes: 1

Modestas Stankevičius
Modestas Stankevičius

Reputation: 144

Try adding a sorf field or something where would be

id value
1    I
2    II
3    III

and so on

Upvotes: 1

Related Questions