Help with simple data manipulation

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mshita
Forum Commoner
Posts: 32
Joined: Sat Jul 03, 2004 8:55 pm
Location: Portland, OR
Contact:

Help with simple data manipulation

Post 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
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Code: Select all

$new_dato = preg_replace('#\.+$#','',$dato);
mshita
Forum Commoner
Posts: 32
Joined: Sat Jul 03, 2004 8:55 pm
Location: Portland, OR
Contact:

Post by mshita »

ummm....thanks for the reply, but that was greek to me :)
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

it should strip all trailing periods in whatever you pass it.. ($dato)
mshita
Forum Commoner
Posts: 32
Joined: Sat Jul 03, 2004 8:55 pm
Location: Portland, OR
Contact:

Post by mshita »

Ah, thank you!
Post Reply