Tema: PHP Fontele
Pogledajte određenu poruku
Staro 16. 01. 2011.   #4
webarto
expert
Grand Master
 
Avatar webarto
 
Datum učlanjenja: 11.04.2010
Poruke: 998
Hvala: 141
959 "Hvala" u 153 poruka
webarto is on a distinguished roadwebarto is on a distinguished roadwebarto is on a distinguished roadwebarto is on a distinguished roadwebarto is on a distinguished roadwebarto is on a distinguished roadwebarto is on a distinguished roadwebarto is on a distinguished road
Default

E'o i kratka bez validacije, pod uslovom da će unijeti ispravno, nije bitno u kojem formatu. Ja recimo ovaj format koristim za SMS poruke.

PHP kôd:
function telefon($broj){
       
    
$broj preg_replace("#[^0-9]#"""$broj);
    if(
substr($broj02) == "00"$broj substr_replace($broj""02);
    if(
substr($broj01) == "0"$broj substr_replace($broj"387"01);

    return 
$broj;
}

echo 
telefon("00 387 61/058-505"); //38761058505
echo telefon("061 / 05 - 85 - 05"); //38761058505
echo telefon("+387 61 05 85 05"); //38761058505 
webarto je offline   Odgovorite uz citat