Romanian PC Forum Sabitech Media - web design, gazduire web, promovare, seo, logo design si branding


Go Back   Romanian PC Forum > Forum General > Webmaster's Section > Script-uri Web

Script-uri Web Instalare/configurare, care e alegerea perfecta pentru tine? Totul despre Forum-uri: instalare, modificare, skin-uri...


Reply
 
Thread Tools
Old 05.01.2011, 11:03   #1
Zuzuitu'
RPC Gold Member
 
Zuzuitu''s Avatar
 
Join Date: 27.05.2009
Location: .it
Age: 28
Posts: 179
Thanks: 69
Thanked 135 Times in 78 Posts
Send a message via Yahoo to Zuzuitu'
Post [PHP] Elimina caractere NON ASCII

Eliminare caractere nedorite:

Code:
<?php
//Un string normal
$rpcstring = "Acestea sunt niste caractere €ž pe care noi nu le dorim.";

//Ce nu ne trebuie se inlocuieste cu un spatiu 
$badrpc = array("&nbsp;");
$rpcstring = trim(str_replace($badrpc," ",$rpcstring));

//Specificam ce trebuie inlocuit
$celrau =     array("“","”","‘","’","…","—","–");
$celbun = array("\"","\"","'","'","...","-","-");
$rpcstring = str_replace($celrau,$celbun,$rpcstring);

//Eliminati toate caractere non ASCII (aka: Microsoft Word şi Perfect word)
$rpcstring = preg_replace('/[^(\x20-\x7F)\x0A]*/','', $rpcstring);

echo $rpcstring;
?>
$rpcstring se va afisa fara caracterele nedorite


Rezultat:
Code:
Acestea sunt niste caractere pe care noi nu le dorim.
Pentru alte caractere:
Code:
<?php

function normalize ($string) {
    $table = array(
        'Š'=>'S', 'š'=>'s', 'Đ'=>'Dj', 'đ'=>'dj', 'Ž'=>'Z', 'ž'=>'z', 'Č'=>'C', 'č'=>'c', 'Ć'=>'C', 'ć'=>'c',
        ''=>'A', ''=>'A', ''=>'A', ''=>'A', ''=>'A', ''=>'A', ''=>'A', ''=>'C', ''=>'E', ''=>'E',
        ''=>'E', ''=>'E', ''=>'I', ''=>'I', ''=>'I', ''=>'I', ''=>'N', ''=>'O', ''=>'O', ''=>'O',
        ''=>'O', ''=>'O', ''=>'O', ''=>'U', ''=>'U', ''=>'U', ''=>'U', ''=>'Y', ''=>'B', ''=>'Ss',
        ''=>'a', ''=>'a', ''=>'a', ''=>'a', ''=>'a', ''=>'a', ''=>'a', ''=>'c', ''=>'e', ''=>'e',
        ''=>'e', ''=>'e', ''=>'i', ''=>'i', ''=>'i', ''=>'i', ''=>'o', ''=>'n', ''=>'o', ''=>'o',
        ''=>'o', ''=>'o', ''=>'o', ''=>'o', ''=>'u', ''=>'u', ''=>'u', ''=>'y', ''=>'y', ''=>'b',
        ''=>'y', 'Ŕ'=>'R', 'ŕ'=>'r',
    );
   
    return strtr($string, $table);
}

?>
Enjoy !
__________________
If you can't afford, just pirate it !
If you still like it when you can afford it in the future, buy it then. Also don't forget to feel bad
!


Daca ai nevoie de ajutorul meu, nu ezita sa ma contactezi !

Last edited by Zuzuitu'; 05.01.2011 at 11:07.
Zuzuitu' is offline   Reply With Quote
The Following 2 Users Say Thank You to Zuzuitu' For This Useful Post:
spany (05.01.2011), XVanish (05.01.2011)
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

 
Advertisement




camere foto digitale

aparate foto digitale


Partner Links
Sabitech Media - dezvoltare web, servicii media

RSP Forum - sateliti.info
Comunitate Satelitara






All times are GMT +2. The time now is 04:01.


Powered by vBulletin - Jelsoft Enterprises Ltd.
~ Copyright 2007-2015 Romanian PC Forum ~
Toate drepturile rezervate

Romanian Sattelites Provider Wi-Fi Magazin