Reputation: 11
Here is my code:
$column5 = array(
'london-airport',
'newyork-airport',
'paris-airport',
'barcelona-international-airport'
);
foreach ($column5 as $airport) {
$btitle = str_replace("-", " ", $airport);
$title = ucwords($btitle);
echo '<h3>'.$title.'</h3>';
}
This will output "london airport" instead of "London Airport". I want it to display the second way.
I also tried:
$btitle = str_replace(strtolower("-", " ", $airport));
$btitle = str_replace(strtolower(trim("-", " ", $airport)));
$btitle = str_replace(trim("-", " ", $airport));
But without success, any suggestions?
Upvotes: 0
Views: 500
Reputation: 128
The code is right, it worked for me. Also, ucwords was introduced in PHP 4 so will not work in order version if in case yours is. http://php.net/manual/en/function.ucwords.php
Upvotes: 1