...

View Full Version : strtlower and ucfirst for Feed



GenVic
09-15-2009, 05:53 PM
I'm pulling in some rss feeds with magpierss, but some are in all caps. How can I change it so that only the first letter is capitalized?


<?php $rss2 = fetch_rss('http://myfeedsite.com/feed');
if ($rss2) {

$items = array_slice($rss2->items, 0, 10);

foreach ($items as $item )

//My FIX WHICH ISN"T WORKING
$item = ucfirst(strtolower($item));

{ echo '<li><a href="'.$item['link'].'">'.$item['title'].'</a></li>'; }
}else
{
echo '<h2>Error:</h2><p>'.magpie_error().'</p>';
}

@ini_restore('error_reporting');
?>

Fumigator
09-15-2009, 05:57 PM
$item is an array; you have to apply the functions to the elements inside the array, not the array itself.

djm0219
09-15-2009, 06:23 PM
$item['title'] = ucfirst(strtolower($item['title']));

GenVic
09-15-2009, 06:31 PM
$item['title'] = ucfirst(strtolower($item['title']));


Perfect. Thanks.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum