June 28, 2010

how to replace hyphen with blank space / white space? php

Question by mali

i don’t know much about PHP but these days I’m modifying an existing script. I want to know how can I replace – with white or blank space

For example a variable contains ‘Love-you’ and I want to replace this hyphen between them with a space like this ‘Love you’.

I’ll appreciate your feed back.

Answer by Starx

You can also use explode and implode

Here is an example

$string = "Love-You";
$arr = explode("-",$string);
$string = implode(" ",$arr);

Author: Nabin Nepal (Starx)

Hello, I am Nabin Nepal and you can call me Starx. This is my blog where write about my life and my involvements. I am a Software Developer, A Cyclist and a Realist. I hope you will find my blog interesting. Follow me on Google+

...

Please fill the form - I will response as fast as I can!