PDA

View Full Version : How do you convert a blank space to a character?



unrelenting
01-05-2008, 08:58 PM
What code would I use to convert a blank space in a query to a character, namely a period.

I want to parse this:

sample query text or possibly numbers

to this:

sample.query.text.or.possibly.numbers

I wouldn't need periods before or after the query.

Can anyone fill me in on this?

mlseim
01-05-2008, 09:05 PM
<?php
$string="sample query text or possibly numbers";
$string=str_replace(" ", ".", $string);
echo $string;
?>

result is:
sample.query.text.or.possibly.numbers

unrelenting
01-05-2008, 09:13 PM
<?php
$string="sample query text or possibly numbers";
$string=str_replace(" ", ".", $string);
echo $string;
?>

result is:
sample.query.text.or.possibly.numbers

Much obliged. :thumbsup: