Rickstar
Rickstar

Reputation: 6189

replace spaces with _ in php

i am trying to replace spaces with underscore '_' in the following variable

 $e_type = 'Hello World TEST';

can anyone help me please

Upvotes: 14

Views: 32802

Answers (3)

Quentin
Quentin

Reputation: 943569

str_replace

Upvotes: 8

Matt
Matt

Reputation: 44058

You want str_replace:

$e_type = str_replace(' ', '_', $e_type);

Upvotes: 51

Chathuranga Chandrasekara
Chathuranga Chandrasekara

Reputation: 20906

Check this. You have some nice examples there...

Upvotes: 4

Related Questions