Jump to content

Search Array and replace in one swoop


mjahkoh

Recommended Posts

<?php

$title = array(
'Category :',
'LocaTioN:',
'addResS:',
'Telephone:',
'City:',
'RegIo n:',
'Description :'
);

foreach ($title as $str)
{
$str = preg_replace('/\s/', '', $str); // remove spaces
$str = preg_replace('/:/', '', $str); // remove colons
$str = ucfirst(strtolower($str)); // capitalize first letter of word (ucwords if multiple words but then dont remove spaces)

$titles[] = $str;
}

print_r($titles);

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.