mjahkoh Posted August 19, 2011 Share Posted August 19, 2011 $title = array('Category :','Location:','Address:','Telephone:','City:','Region:','Description :'); How possible is it search for eg spaces and ":" in the array and replace them with nothing and capitalize elements. Regards, Jackson Link to comment https://forums.phpfreaks.com/topic/245203-search-array-and-replace-in-one-swoop/ Share on other sites More sharing options...
codefossa Posted August 19, 2011 Share Posted August 19, 2011 <?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); ?> Link to comment https://forums.phpfreaks.com/topic/245203-search-array-and-replace-in-one-swoop/#findComment-1259418 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.