problem with a skipurl function, please help

Discussion in 'PHP' started by free-designer, Mar 3, 2010.

  1. #1
    this function

    
        function skipURL($string){
    		$string = preg_replace("`\[.*\]`U","",$string);
    		$string = preg_replace('`&(amp;)?#?[a-z0-9]+;`i','-',$string);
    		$string = htmlentities($string, ENT_COMPAT, 'utf-8');
    		$string = preg_replace( "`&([a-z])(acute|uml|circ|grave|ring|cedil|slash|tilde|caron|lig|quot|rsquo);`i","\\1", $string );
    		$string = preg_replace( array("`[^a-z0-9]`i","`[-]+`") , "-", $string);
    		return strtolower(trim($string, '-'));
    	}
    
    
    PHP:
    this works like what i need.

    but im haveing a problem this function works good with english language but what if there is any kind of other language

    like arabic for examble

    if i have this string with english

    LOREM _ DolOr :^*(

    the function going to make like that

    lorem-dolor

    but what if there a string like that

    english :: عربى

    it's going to be like that

    english

    i just want it to be like that

    english-عربى

    so please if anyone can help me with this

    thanks
     
    free-designer, Mar 3, 2010 IP
  2. bitist

    bitist Peon

    Messages:
    28
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    There is an encoding problem.
    Instead of using strtolower() you should use mb_strtolower().
     
    bitist, Mar 3, 2010 IP
  3. free-designer

    free-designer Peon

    Messages:
    79
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    also not working sorry,

    the arabic language characters also not showing

    please if you have any other idea
     
    free-designer, Mar 3, 2010 IP
  4. free-designer

    free-designer Peon

    Messages:
    79
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    any ideas?
     
    free-designer, Mar 3, 2010 IP
  5. HivelocityDD

    HivelocityDD Peon

    Messages:
    179
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Set encoding properly to UTF-8 and make use of the mb_strtolower() and mb_string() in combination. I dont know any thing other than that.

    Also try to set the locale as arabic if needed.
     
    HivelocityDD, Mar 4, 2010 IP
  6. free-designer

    free-designer Peon

    Messages:
    79
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    thanks for answering, but i've solved the problem.
    thanks again
     
    free-designer, Mar 4, 2010 IP
  7. isset()

    isset() Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    the current php functions not support arabic but you can make strtolower_ar()
    just use replace functions
     
    isset(), Mar 4, 2010 IP