![]() |
Revising text file from ALL CAPS to First Letter Caps.. php script?
Another PHP question. I have a list of 10,000+ phrases line by line in a text file. I need to change it from:
THE BOY JOHNS BIRD FRED SUCKS EAT ME etc etc to: The Boy Johns Bird Fred Sucks Eat Me etc etc Anyone know a php code or easy program/way to do this? |
$file = str_replace("A","a","$file");
$file = str_replace("B","b","$file"); go all the way to Z... thats really the easiest way that I can think of... obviously theres others but this is a quick way. I've been up all night coding so can't think of a "cleaner" way to do it... |
just noticed that you want to keep the caps after a space... alright, that complicates it a bit more... but str_replace can do that too.... just have a space as part of the syntax
|
Code:
$db = file("filename.txt"); |
Code:
<?phpput words in a file called file.txt visit php ina browser |
Quote:
|
Quote:
If not then replacing \n with <br>\n on the third last line should do the trick. |
Use ucwords($string);
|
wtf are you guys smoking?
<?php $file=file('somefiletxt'); $file=array_map('strtolower',$file); $file=array_map('ucwords',$file); echo implode('',$file); ?> |
| All times are GMT -7. The time now is 03:50 AM. |
Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123