Jump to content

Parse Months In cyrillic letters to numbers


xfire123

Recommended Posts

Hello im trying to search this kind of parse. I have this string in variable:

$a = "май 2017";

How to parse to for example: "5 2017" or "5 17" or "5"

I can parse it from EN text but with cyrillic text i cant...

Please help

 

b.t.w i cant use array to store all cyrillic months because they coming from different script.

Link to comment
Share on other sites

 

This is my code:

 

if $filename = "Май 2017"

                    <?php
                        $dir_open = opendir('./WEBDams/Data/CHQ/HQ/1/');
                        while(false !== ($filename = readdir($dir_open))){
                                if($filename != "." && $filename != ".."){
                                    setlocale(LC_TIME, 'bg_BG.UTF-8','bulgarian');
                                    $filenameNOext = basename($filename, '.pdf');
                                    $filenameNOext2 = strftime($filenameNOext);
                                    $filenameNOext3 = preg_replace('/\d/', '', $filenameNOext2);
                                    $filenameNOext4 = preg_replace('/\s+/', '', $filenameNOext3);
                                    
                                    $link = "<li class='sort-item' data-event-date='$filenameNOext4'><a href='./WEBDams/Data/CHQ/HQ/1/$filename' ><strong> $filenameNOext г. $filenameNOext3</strong></a></li>";
                                    echo $link;
                                }
                        }
                        closedir($dir_open);

Im using it with this script:

    (function($){
    var container = $(".sort-list");
    var items = $(".sort-item");
    
    items.each(function() {
       // Convert the string in 'data-event-date' attribute to a more
       // standardized date format
       var BCDate = $(this).attr("data-event-date");
       var standardDate = BCDate[0];
       standardDate = new Date(standardDate).getTime();
       $(this).attr("data-event-date", standardDate);
 
    });
    

    items.sort(function(a,b){
        a = parseFloat($(a).attr("data-event-date"));
        b = parseFloat($(b).attr("data-event-date"));
        return a>b ? -1 : a<b ? 1 : 0;
    }).each(function(){
        container.prepend(this);
    });

})(jQuery);

/* This script sorts your list in descending order... to change it to ascending order change the "less than" operator (<) to "greater than" (>) */

But its not working for some reason... can you give me an example?

Link to comment
Share on other sites

It giving me:

Fatal error: Uncaught Error: Class 'IntlDateFormatter' not found in C:\WEB\Apache24\htdocs\inc_req\menu_HQ.php:2 Stack trace: #0 C:\WEB\Apache24\htdocs\HQ.php(20): require() #1 {main} thrown in C:\WEB\Apache24\htdocs\inc_req\menu_HQ.php on line 2

I comment out extension=php_intl.dll restarted service. Still same error.

Link to comment
Share on other sites

its say:

PHP Warning:  PHP Startup: Unable to load dynamic library 'C:\\WEB\\PHP\\ext\\php_intl.dll' - The specified module could not be found.\r\n in Unknown on line 0

I fixed it when i copy all icu*.dll files in Apache bin directory... at last

 

I tested it and works like a charm. Thank you very much.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.