Page 1 of 1

Help with simple data manipulation

Posted: Sat Jul 03, 2004 8:55 pm
by mshita
I have some newbie questions.

So I have $dato = "1234...."

I know the length of $dato is always 8 characters. Anything besides '.' is valid. But I don't know how many '.' there are, just that they are padded to the end.

How do I go about to remove them?

Cheers,
Mounir

Posted: Sat Jul 03, 2004 9:19 pm
by feyd

Code: Select all

$new_dato = preg_replace('#\.+$#','',$dato);

Posted: Sat Jul 03, 2004 9:20 pm
by mshita
ummm....thanks for the reply, but that was greek to me :)

Posted: Sat Jul 03, 2004 9:22 pm
by feyd
it should strip all trailing periods in whatever you pass it.. ($dato)

Posted: Sat Jul 03, 2004 9:24 pm
by mshita
Ah, thank you!