Forums

PHP

This topic is locked

Space bahavior

Posted 19 Feb 2002 19:09:38
1
has voted
19 Feb 2002 19:09:38 enquest enquest1 posted:
How would I make a behavior that makes a space in a word befor a capital letter. In my database I have words refering to files but sometimes it are two words. example
BerryBlue has to become "Berry Bleu".

Any body know how to?

Replies

Replied 20 Feb 2002 09:33:33
20 Feb 2002 09:33:33 Bruno Mairlot replied:
Enquest,

try the following code :

<pre id=code><font face=courier size=2 id=code>
&lt;?php
$val="BlueBerry";
echo preg_replace("/([A-Z])/"," \\1",$val);
?&gt;
</font id=code></pre id=code>

In essence, it checks for every uppercase letter, and insert a space in front of it.

Maybe you could refine the regular expression, depending on your needs.

Bruno

--- Better to die trying, than never try at all ---

Reply to this topic