Home > General > Affiliate Marketing Forum

Need help with ucwords - quick coding help required plz? (4)


12-24-2012 06:24 PM #1 vidivo (Member)
Need help with ucwords - quick coding help required plz?

Hey,

I have this code, but currently it spits out everything in all caps, they told me to use ucwords to fix it but I have no idea how. Any coders out there willing to help for this quick fix? Thanks!

Code:
<?php
require_once('ip2location.class.php');
$ip = new ip2location;
$ip->open('ip2location/databases/IP-COUNTRY-REGION-CITY.BIN');
$record = $ip->getAll($_SERVER["REMOTE_ADDR"]);
echo ' Country Long: ' . $record->countryLong; 
echo ' Region: ' . $record->region ; 
echo ' City: ' . $record->city ;
?>


12-24-2012 07:24 PM #2 dextrous (Member)

You want it to print contents with only the first letter uppercase and others lower, like "Washington" & "America" ?

Try this for example:
[PHP]
<?php
require_once('ip2location.class.php');
$ip = new ip2location;
$ip->open('ip2location/databases/IP-COUNTRY-REGION-CITY.BIN');
$record = $ip->getAll($_SERVER["REMOTE_ADDR"]);

$country = ucfirst(strtolower($record->countryLong));
$region = ucfirst(strtolower($record->region));
$city = ucfirst(strtolower($record->city));

echo ' Country Long: ' . $country;
echo ' Region: ' . $region;
echo ' City: ' . $city;
?>
[/PHP]


12-24-2012 07:37 PM #3 vidivo (Member)

PERFECT! Thanks so much!


12-24-2012 08:03 PM #4 dextrous (Member)

Cool, no problem bro!


Home > General > Affiliate Marketing Forum